From 45135da709025645bc42555c5d47d966add75a8b Mon Sep 17 00:00:00 2001 From: Jeremy Holtzman Date: Mon, 10 Apr 2023 13:59:24 -0400 Subject: [PATCH 1/6] adding database and schema property to generate source macro --- CHANGELOG.md | 1 + README.md | 1 + integration_tests/tests/test_generate_source.sql | 2 ++ integration_tests/tests/test_generate_source_all_args.sql | 2 ++ integration_tests/tests/test_generate_source_exclude.sql | 2 ++ integration_tests/tests/test_generate_source_some_tables.sql | 2 ++ .../tests/test_generate_source_table_descriptions.sql | 2 ++ integration_tests/tests/test_generate_source_table_name.sql | 1 + .../tests/test_generate_source_table_pattern.sql | 2 ++ macros/generate_source.sql | 4 ---- 10 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e37590..8d46a02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/README.md b/README.md index 472ae8a..996ffcc 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ version: 2 sources: - name: raw_jaffle_shop database: raw + schema: raw_jaffle_shop tables: - name: customers description: "" diff --git a/integration_tests/tests/test_generate_source.sql b/integration_tests/tests/test_generate_source.sql index ce48bd6..324b6c0 100644 --- a/integration_tests/tests/test_generate_source.sql +++ b/integration_tests/tests/test_generate_source.sql @@ -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 diff --git a/integration_tests/tests/test_generate_source_all_args.sql b/integration_tests/tests/test_generate_source_all_args.sql index fb46970..8a5b983 100644 --- a/integration_tests/tests/test_generate_source_all_args.sql +++ b/integration_tests/tests/test_generate_source_all_args.sql @@ -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: "" diff --git a/integration_tests/tests/test_generate_source_exclude.sql b/integration_tests/tests/test_generate_source_exclude.sql index e1bd85d..e86a468 100644 --- a/integration_tests/tests/test_generate_source_exclude.sql +++ b/integration_tests/tests/test_generate_source_exclude.sql @@ -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 diff --git a/integration_tests/tests/test_generate_source_some_tables.sql b/integration_tests/tests/test_generate_source_some_tables.sql index 525f712..a29cb53 100644 --- a/integration_tests/tests/test_generate_source_some_tables.sql +++ b/integration_tests/tests/test_generate_source_some_tables.sql @@ -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: "" diff --git a/integration_tests/tests/test_generate_source_table_descriptions.sql b/integration_tests/tests/test_generate_source_table_descriptions.sql index 772c637..ca917e4 100644 --- a/integration_tests/tests/test_generate_source_table_descriptions.sql +++ b/integration_tests/tests/test_generate_source_table_descriptions.sql @@ -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: "" diff --git a/integration_tests/tests/test_generate_source_table_name.sql b/integration_tests/tests/test_generate_source_table_name.sql index a636ac0..dce934d 100644 --- a/integration_tests/tests/test_generate_source_table_name.sql +++ b/integration_tests/tests/test_generate_source_table_name.sql @@ -9,6 +9,7 @@ version: 2 sources: - name: raw + database: analytics schema: {{ raw_schema | trim | lower }} tables: - name: data__a_relation diff --git a/integration_tests/tests/test_generate_source_table_pattern.sql b/integration_tests/tests/test_generate_source_table_pattern.sql index 7818ed9..85eaa7d 100644 --- a/integration_tests/tests/test_generate_source_table_pattern.sql +++ b/integration_tests/tests/test_generate_source_table_pattern.sql @@ -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 %} diff --git a/macros/generate_source.sql b/macros/generate_source.sql index df81053..948e36a 100644 --- a/macros/generate_source.sql +++ b/macros/generate_source.sql @@ -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:') %} From fb1db60cc67917cf95ca6fc1c05f28c7cdb7373c Mon Sep 17 00:00:00 2001 From: Jeremy Holtzman Date: Mon, 1 May 2023 11:04:17 -0400 Subject: [PATCH 2/6] add optional arguments to include database and schema properties in generate_source --- CHANGELOG.md | 4 ++-- .../tests/test_generate_source.sql | 5 +---- .../tests/test_generate_source_all_args.sql | 7 +++++-- .../tests/test_generate_source_exclude.sql | 2 -- ...erate_source_include_database_property.sql | 19 +++++++++++++++++++ ...enerate_source_include_schema_property.sql | 19 +++++++++++++++++++ .../test_generate_source_some_tables.sql | 4 +--- ...est_generate_source_table_descriptions.sql | 4 +--- .../tests/test_generate_source_table_name.sql | 3 +-- .../test_generate_source_table_pattern.sql | 4 +--- macros/generate_source.sql | 8 ++++++-- 11 files changed, 56 insertions(+), 23 deletions(-) create mode 100644 integration_tests/tests/test_generate_source_include_database_property.sql create mode 100644 integration_tests/tests/test_generate_source_include_schema_property.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d46a02..6f1d566 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +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)) +- Add optional arguments to 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)) @@ -151,4 +151,4 @@ Bump utils version range Small quality of life improvements # dbt-codegen v0.0.1 -Initial release +Initial release \ No newline at end of file diff --git a/integration_tests/tests/test_generate_source.sql b/integration_tests/tests/test_generate_source.sql index 324b6c0..35ac13d 100644 --- a/integration_tests/tests/test_generate_source.sql +++ b/integration_tests/tests/test_generate_source.sql @@ -1,4 +1,3 @@ - {% set raw_schema = generate_schema_name('raw_data') %} -- test default args @@ -9,8 +8,6 @@ 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 @@ -18,4 +15,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file diff --git a/integration_tests/tests/test_generate_source_all_args.sql b/integration_tests/tests/test_generate_source_all_args.sql index 8a5b983..1511dfc 100644 --- a/integration_tests/tests/test_generate_source_all_args.sql +++ b/integration_tests/tests/test_generate_source_all_args.sql @@ -9,7 +9,10 @@ generate_columns=True, include_descriptions=True, include_data_types=True, - name=raw_schema + name=raw_schema, + table_names=None, + include_database_property=True, + include_schema_property=True ) %} @@ -64,4 +67,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file diff --git a/integration_tests/tests/test_generate_source_exclude.sql b/integration_tests/tests/test_generate_source_exclude.sql index e86a468..e1bd85d 100644 --- a/integration_tests/tests/test_generate_source_exclude.sql +++ b/integration_tests/tests/test_generate_source_exclude.sql @@ -9,8 +9,6 @@ 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 diff --git a/integration_tests/tests/test_generate_source_include_database_property.sql b/integration_tests/tests/test_generate_source_include_database_property.sql new file mode 100644 index 0000000..d8d916a --- /dev/null +++ b/integration_tests/tests/test_generate_source_include_database_property.sql @@ -0,0 +1,19 @@ + +{% set raw_schema = generate_schema_name('raw_data') %} + +{% set actual_source_yaml = codegen.generate_source(raw_schema, include_database_property=True) %} + +{% set expected_source_yaml %} +version: 2 + +sources: + - name: {{ raw_schema | trim | lower }} + database: analytics + tables: + - name: data__a_relation + - name: data__b_relation + - name: data__campaign_analytics +{% endset %} + + +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file diff --git a/integration_tests/tests/test_generate_source_include_schema_property.sql b/integration_tests/tests/test_generate_source_include_schema_property.sql new file mode 100644 index 0000000..d6c29f4 --- /dev/null +++ b/integration_tests/tests/test_generate_source_include_schema_property.sql @@ -0,0 +1,19 @@ + +{% set raw_schema = generate_schema_name('raw_data') %} + +{% set actual_source_yaml = codegen.generate_source(raw_schema, include_schema_property=True) %} + +{% set expected_source_yaml %} +version: 2 + +sources: + - name: {{ raw_schema | trim | lower }} + schema: {{ raw_schema | trim | lower }} + tables: + - name: data__a_relation + - name: data__b_relation + - name: data__campaign_analytics +{% endset %} + + +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file diff --git a/integration_tests/tests/test_generate_source_some_tables.sql b/integration_tests/tests/test_generate_source_some_tables.sql index a29cb53..c2a2140 100644 --- a/integration_tests/tests/test_generate_source_some_tables.sql +++ b/integration_tests/tests/test_generate_source_some_tables.sql @@ -16,8 +16,6 @@ version: 2 sources: - name: {{ raw_schema | trim | lower }} description: "" - database: analytics - schema: codegen_integration_tests_snowflake_raw_data tables: - name: data__a_relation description: "" @@ -29,4 +27,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file diff --git a/integration_tests/tests/test_generate_source_table_descriptions.sql b/integration_tests/tests/test_generate_source_table_descriptions.sql index ca917e4..01d23e4 100644 --- a/integration_tests/tests/test_generate_source_table_descriptions.sql +++ b/integration_tests/tests/test_generate_source_table_descriptions.sql @@ -10,8 +10,6 @@ version: 2 sources: - name: {{ raw_schema | trim | lower }} description: "" - database: analytics - schema: codegen_integration_tests_snowflake_raw_data tables: - name: data__a_relation description: "" @@ -22,4 +20,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file diff --git a/integration_tests/tests/test_generate_source_table_name.sql b/integration_tests/tests/test_generate_source_table_name.sql index dce934d..fb97577 100644 --- a/integration_tests/tests/test_generate_source_table_name.sql +++ b/integration_tests/tests/test_generate_source_table_name.sql @@ -9,7 +9,6 @@ version: 2 sources: - name: raw - database: analytics schema: {{ raw_schema | trim | lower }} tables: - name: data__a_relation @@ -19,4 +18,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file diff --git a/integration_tests/tests/test_generate_source_table_pattern.sql b/integration_tests/tests/test_generate_source_table_pattern.sql index 85eaa7d..c13a26e 100644 --- a/integration_tests/tests/test_generate_source_table_pattern.sql +++ b/integration_tests/tests/test_generate_source_table_pattern.sql @@ -9,11 +9,9 @@ version: 2 sources: - name: {{ raw_schema | trim | lower }} - database: analytics - schema: codegen_integration_tests_snowflake_raw_data tables: - name: data__b_relation {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file diff --git a/macros/generate_source.sql b/macros/generate_source.sql index 948e36a..75bb8d3 100644 --- a/macros/generate_source.sql +++ b/macros/generate_source.sql @@ -15,7 +15,7 @@ --- -{% macro generate_source(schema_name, database_name=target.database, generate_columns=False, include_descriptions=False, include_data_types=False, table_pattern='%', exclude='', name=schema_name, table_names=None) %} +{% macro generate_source(schema_name, database_name=target.database, generate_columns=False, include_descriptions=False, include_data_types=False, table_pattern='%', exclude='', name=schema_name, table_names=None, include_database_property=False, include_schema_property=False) %} {% set sources_yaml=[] %} {% do sources_yaml.append('version: 2') %} @@ -27,9 +27,13 @@ {% do sources_yaml.append(' description: ""' ) %} {% endif %} +{% if database_name != target.database or include_database_property %} {% do sources_yaml.append(' database: ' ~ database_name | lower) %} +{% endif %} +{% if schema_name != name or include_schema_property %} {% do sources_yaml.append(' schema: ' ~ schema_name | lower) %} +{% endif %} {% do sources_yaml.append(' tables:') %} @@ -78,4 +82,4 @@ {% endif %} -{% endmacro %} +{% endmacro %} \ No newline at end of file From 159fa3e9d2b750fb9ef4d1784f437d282d889264 Mon Sep 17 00:00:00 2001 From: Jeremy Holtzman Date: Mon, 1 May 2023 11:09:00 -0400 Subject: [PATCH 3/6] updated README for new generate_source arguments --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 996ffcc..642aa5b 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,10 @@ types to your source columns definitions. want to subselect from all available tables within a given schema. * `exclude` (optional, default=''): A string you want to exclude from the selection criteria * `name` (optional, default=schema_name): The name of your source +* `include_database_property` (optional, default=False): Whether you want to add +the database property to your source definition +* `include_schema_property` (optional, default=False): Whether you want to add +the schema property to your source definition ### Usage: 1. Copy the macro into a statement tab in the dbt Cloud IDE, or into an analysis file, and compile your code From b954c244700d3d8577e9021062f6fb37332d9627 Mon Sep 17 00:00:00 2001 From: Jeremy Holtzman Date: Mon, 1 May 2023 12:48:04 -0400 Subject: [PATCH 4/6] updated argument names and cleaned up spacing --- README.md | 8 ++++---- integration_tests/tests/test_generate_source.sql | 3 ++- integration_tests/tests/test_generate_source_all_args.sql | 6 +++--- .../test_generate_source_include_database_property.sql | 4 ++-- .../test_generate_source_include_schema_property.sql | 4 ++-- .../tests/test_generate_source_some_tables.sql | 2 +- .../tests/test_generate_source_table_descriptions.sql | 2 +- .../tests/test_generate_source_table_name.sql | 2 +- .../tests/test_generate_source_table_pattern.sql | 2 +- macros/generate_source.sql | 6 +++--- 10 files changed, 20 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 642aa5b..481b07f 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,10 @@ types to your source columns definitions. want to subselect from all available tables within a given schema. * `exclude` (optional, default=''): A string you want to exclude from the selection criteria * `name` (optional, default=schema_name): The name of your source -* `include_database_property` (optional, default=False): Whether you want to add -the database property to your source definition -* `include_schema_property` (optional, default=False): Whether you want to add -the schema property to your source definition +* `include_database` (optional, default=False): Whether you want to add +the database to your source definition +* `include_schema` (optional, default=False): Whether you want to add +the schema to your source definition ### Usage: 1. Copy the macro into a statement tab in the dbt Cloud IDE, or into an analysis file, and compile your code diff --git a/integration_tests/tests/test_generate_source.sql b/integration_tests/tests/test_generate_source.sql index 35ac13d..ce48bd6 100644 --- a/integration_tests/tests/test_generate_source.sql +++ b/integration_tests/tests/test_generate_source.sql @@ -1,3 +1,4 @@ + {% set raw_schema = generate_schema_name('raw_data') %} -- test default args @@ -15,4 +16,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} diff --git a/integration_tests/tests/test_generate_source_all_args.sql b/integration_tests/tests/test_generate_source_all_args.sql index 1511dfc..b6ac69c 100644 --- a/integration_tests/tests/test_generate_source_all_args.sql +++ b/integration_tests/tests/test_generate_source_all_args.sql @@ -11,8 +11,8 @@ include_data_types=True, name=raw_schema, table_names=None, - include_database_property=True, - include_schema_property=True + include_database=True, + include_schema=True ) %} @@ -67,4 +67,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} diff --git a/integration_tests/tests/test_generate_source_include_database_property.sql b/integration_tests/tests/test_generate_source_include_database_property.sql index d8d916a..e64e899 100644 --- a/integration_tests/tests/test_generate_source_include_database_property.sql +++ b/integration_tests/tests/test_generate_source_include_database_property.sql @@ -1,7 +1,7 @@ {% set raw_schema = generate_schema_name('raw_data') %} -{% set actual_source_yaml = codegen.generate_source(raw_schema, include_database_property=True) %} +{% set actual_source_yaml = codegen.generate_source(raw_schema, include_database=True) %} {% set expected_source_yaml %} version: 2 @@ -16,4 +16,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} diff --git a/integration_tests/tests/test_generate_source_include_schema_property.sql b/integration_tests/tests/test_generate_source_include_schema_property.sql index d6c29f4..6fe08f7 100644 --- a/integration_tests/tests/test_generate_source_include_schema_property.sql +++ b/integration_tests/tests/test_generate_source_include_schema_property.sql @@ -1,7 +1,7 @@ {% set raw_schema = generate_schema_name('raw_data') %} -{% set actual_source_yaml = codegen.generate_source(raw_schema, include_schema_property=True) %} +{% set actual_source_yaml = codegen.generate_source(raw_schema, include_schema=True) %} {% set expected_source_yaml %} version: 2 @@ -16,4 +16,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} diff --git a/integration_tests/tests/test_generate_source_some_tables.sql b/integration_tests/tests/test_generate_source_some_tables.sql index c2a2140..525f712 100644 --- a/integration_tests/tests/test_generate_source_some_tables.sql +++ b/integration_tests/tests/test_generate_source_some_tables.sql @@ -27,4 +27,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} diff --git a/integration_tests/tests/test_generate_source_table_descriptions.sql b/integration_tests/tests/test_generate_source_table_descriptions.sql index 01d23e4..772c637 100644 --- a/integration_tests/tests/test_generate_source_table_descriptions.sql +++ b/integration_tests/tests/test_generate_source_table_descriptions.sql @@ -20,4 +20,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} diff --git a/integration_tests/tests/test_generate_source_table_name.sql b/integration_tests/tests/test_generate_source_table_name.sql index fb97577..a636ac0 100644 --- a/integration_tests/tests/test_generate_source_table_name.sql +++ b/integration_tests/tests/test_generate_source_table_name.sql @@ -18,4 +18,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} diff --git a/integration_tests/tests/test_generate_source_table_pattern.sql b/integration_tests/tests/test_generate_source_table_pattern.sql index c13a26e..7818ed9 100644 --- a/integration_tests/tests/test_generate_source_table_pattern.sql +++ b/integration_tests/tests/test_generate_source_table_pattern.sql @@ -14,4 +14,4 @@ sources: {% endset %} -{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} \ No newline at end of file +{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} diff --git a/macros/generate_source.sql b/macros/generate_source.sql index 75bb8d3..eff3fa7 100644 --- a/macros/generate_source.sql +++ b/macros/generate_source.sql @@ -15,7 +15,7 @@ --- -{% macro generate_source(schema_name, database_name=target.database, generate_columns=False, include_descriptions=False, include_data_types=False, table_pattern='%', exclude='', name=schema_name, table_names=None, include_database_property=False, include_schema_property=False) %} +{% macro generate_source(schema_name, database_name=target.database, generate_columns=False, include_descriptions=False, include_data_types=False, table_pattern='%', exclude='', name=schema_name, table_names=None, include_database=False, include_schema=False) %} {% set sources_yaml=[] %} {% do sources_yaml.append('version: 2') %} @@ -27,11 +27,11 @@ {% do sources_yaml.append(' description: ""' ) %} {% endif %} -{% if database_name != target.database or include_database_property %} +{% if database_name != target.database or include_database %} {% do sources_yaml.append(' database: ' ~ database_name | lower) %} {% endif %} -{% if schema_name != name or include_schema_property %} +{% if schema_name != name or include_schema %} {% do sources_yaml.append(' schema: ' ~ schema_name | lower) %} {% endif %} From b3bb6222d4425a59e0c2021819d2856ee65ab0b5 Mon Sep 17 00:00:00 2001 From: Jeremy Holtzman Date: Mon, 1 May 2023 12:49:09 -0400 Subject: [PATCH 5/6] cleaned up spacing --- macros/generate_source.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros/generate_source.sql b/macros/generate_source.sql index eff3fa7..5097655 100644 --- a/macros/generate_source.sql +++ b/macros/generate_source.sql @@ -82,4 +82,4 @@ {% endif %} -{% endmacro %} \ No newline at end of file +{% endmacro %} From 5f75aa1440380bb5f066fb4b8c43c314c43dcea7 Mon Sep 17 00:00:00 2001 From: Jeremy Holtzman Date: Mon, 1 May 2023 13:00:46 -0400 Subject: [PATCH 6/6] fix spacing --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f1d566..58de5f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -151,4 +151,4 @@ Bump utils version range Small quality of life improvements # dbt-codegen v0.0.1 -Initial release \ No newline at end of file +Initial release