-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated generate_model_yaml macro to correctly handle nested bigquery… (
#54) * Updated generate_model_yaml macro to correctly handle nested bigquery fields * Updated changelog.md * Update macros/generate_model_yaml.sql * Integration tests Co-authored-by: Bob De Schutter <bob.deschutter@digitalswat.be> Co-authored-by: Doug Beatty <44704949+dbeatty10@users.noreply.github.com> Co-authored-by: Doug Beatty <doug.beatty@dbtlabs.com>
- Loading branch information
1 parent
046eb72
commit e982a11
Showing
10 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% if target.type == "bigquery" %} | ||
|
||
{#--- This exists to test the BigQuery-specific behavior reqeusted in #27 -#} | ||
select | ||
STRUCT( | ||
source, | ||
medium, | ||
source_medium | ||
) as analytics, | ||
col_x | ||
from {{ ref('data__campaign_analytics') }} | ||
|
||
{% else %} | ||
|
||
{#--- This enables mimicking the BigQuery behavior for other adapters -#} | ||
select | ||
analytics, | ||
source, | ||
medium, | ||
source_medium, | ||
col_x | ||
from {{ ref('data__campaign_analytics') }} | ||
|
||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source,medium,source_medium,analytics,col_x | ||
source_1,medium_a,1a,,x | ||
source_2,medium_b,2b,,x | ||
source_3,medium_c,3c,,x |
42 changes: 42 additions & 0 deletions
42
integration_tests/tests/test_generate_model_struct_yaml.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% set raw_schema = generate_schema_name('raw_data') %} | ||
|
||
-- test all args | ||
{% set actual_source_yaml = codegen.generate_source( | ||
database_name=target.database, | ||
schema_name='codegen_integration_tests__data_source_schema', | ||
table_names=['codegen_integration_tests__data_source_table_nested_array'], | ||
generate_columns=True, | ||
include_descriptions=True | ||
) %} | ||
|
||
{% set actual_source_yaml = codegen.generate_model_yaml( | ||
model_name='model_struct' | ||
) | ||
%} | ||
|
||
|
||
{% set expected_source_yaml %} | ||
version: 2 | ||
|
||
models: | ||
- name: model_struct | ||
description: "" | ||
columns: | ||
- name: analytics | ||
description: "" | ||
|
||
- name: source | ||
description: "" | ||
|
||
- name: medium | ||
description: "" | ||
|
||
- name: source_medium | ||
description: "" | ||
|
||
- name: col_x | ||
description: "" | ||
|
||
{% endset %} | ||
|
||
{{ assert_equal (actual_source_yaml | trim, expected_source_yaml | trim) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters