Skip to content

Commit

Permalink
add database and schema properties to generate_sources
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyholtzman committed Apr 10, 2023
1 parent fe0b776 commit de916e9
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
This macro generates a series of terminal commands (appended w) bash script which creates a new file in your dbt project based off the results of the [generate_base_model](macros/generate_base_model.sql) macro. Therefore, instead of outputting in the terminal, it will create the file for you.
- Add `include_data_types` flag to `generate_source` macro ([#76](https://github.com/dbt-labs/dbt-codegen/pull/76))
- Add `get_models` macro in helper macros. This macro retrieves a list of models with specified prefix at the specified directory. It is designed to make creating yamls for multiple models easier.
- Always include database and schema properties in `sources.yml` generated from `generate_source` ([#123](https://github.com/dbt-labs/dbt-codegen/issues/123))

## Fixes
- Fix handling of nested `STRUCT` fields in BigQuery ([#98](https://github.com/dbt-labs/dbt-codegen/issues/98), [#105](https://github.com/dbt-labs/dbt-codegen/pull/105))
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ version: 2
sources:
- name: raw_jaffle_shop
database: raw
schema: raw_jaffle_shop
tables:
- name: customers
description: ""
Expand Down
6 changes: 6 additions & 0 deletions integration_tests/.env/snowflake.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SNOWFLAKE_TEST_ACCOUNT=
SNOWFLAKE_TEST_USER=
SNOWFLAKE_TEST_PASSWORD=
SNOWFLAKE_TEST_ROLE=
SNOWFLAKE_TEST_DATABASE=
SNOWFLAKE_TEST_WAREHOUSE=
2 changes: 2 additions & 0 deletions integration_tests/tests/test_generate_source.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ version: 2

sources:
- name: {{ raw_schema | trim | lower }}
database: analytics
schema: codegen_integration_tests_snowflake_raw_data
tables:
- name: data__a_relation
- name: data__b_relation
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/tests/test_generate_source_all_args.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ version: 2
sources:
- name: {{ raw_schema | trim | lower }}
description: ""
database: analytics
schema: codegen_integration_tests_snowflake_raw_data
tables:
- name: data__a_relation
description: ""
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/tests/test_generate_source_exclude.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ version: 2

sources:
- name: {{ raw_schema | trim | lower}}
database: analytics
schema: codegen_integration_tests_snowflake_raw_data
tables:
- name: data__b_relation
- name: data__campaign_analytics
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/tests/test_generate_source_some_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ version: 2
sources:
- name: {{ raw_schema | trim | lower }}
description: ""
database: analytics
schema: codegen_integration_tests_snowflake_raw_data
tables:
- name: data__a_relation
description: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ version: 2
sources:
- name: {{ raw_schema | trim | lower }}
description: ""
database: analytics
schema: codegen_integration_tests_snowflake_raw_data
tables:
- name: data__a_relation
description: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ version: 2

sources:
- name: raw
database: analytics
schema: {{ raw_schema | trim | lower }}
tables:
- name: data__a_relation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ version: 2

sources:
- name: {{ raw_schema | trim | lower }}
database: analytics
schema: codegen_integration_tests_snowflake_raw_data
tables:
- name: data__b_relation
{% endset %}
Expand Down
4 changes: 0 additions & 4 deletions macros/generate_source.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@
{% do sources_yaml.append(' description: ""' ) %}
{% endif %}

{% if database_name != target.database %}
{% do sources_yaml.append(' database: ' ~ database_name | lower) %}
{% endif %}

{% if schema_name != name %}
{% do sources_yaml.append(' schema: ' ~ schema_name | lower) %}
{% endif %}

{% do sources_yaml.append(' tables:') %}

Expand Down

0 comments on commit de916e9

Please sign in to comment.