From 42ab138aabdf3d65f4027e7562deaac1ef4d4a14 Mon Sep 17 00:00:00 2001 From: Anders Swanson Date: Thu, 11 Apr 2024 21:29:32 -0400 Subject: [PATCH] actual test case for #257 --- .github/workflows/integration_tests.yml | 1 + integration_tests/dbt_project.yml | 6 ++++ .../models/plugins/snowflake/people_alias.sql | 4 +++ .../plugins/snowflake/snowflake_external.yml | 28 +++++++++++++++---- 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 integration_tests/models/plugins/snowflake/people_alias.sql diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 8c5198a2..0ffbbbb8 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -36,6 +36,7 @@ jobs: export DBT_PROFILES_DIR=. dbt deps --target ${{ matrix.data-platform }} dbt seed --full-refresh --target ${{ matrix.data-platform }} + dbt run --target ${{ matrix.data-platform }} dbt run-operation prep_external --target ${{ matrix.data-platform }} dbt run-operation dbt_external_tables.stage_external_sources --vars 'ext_full_refresh: true' --target ${{ matrix.data-platform }} dbt run-operation dbt_external_tables.stage_external_sources --target ${{ matrix.data-platform }} diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml index 42cd38c0..6de61814 100644 --- a/integration_tests/dbt_project.yml +++ b/integration_tests/dbt_project.yml @@ -24,6 +24,12 @@ dispatch: seeds: +quote_columns: false +models: + dbt_external_tables_integration_tests: + plugins: + snowflake: + +enabled: "{{ target.type == 'snowflake' }}" + sources: dbt_external_tables_integration_tests: plugins: diff --git a/integration_tests/models/plugins/snowflake/people_alias.sql b/integration_tests/models/plugins/snowflake/people_alias.sql new file mode 100644 index 00000000..844fb05a --- /dev/null +++ b/integration_tests/models/plugins/snowflake/people_alias.sql @@ -0,0 +1,4 @@ +SELECT + {{ dbt_utils.star(from=ref('people'), except=['email']) }}, + email as email_alias +FROM {{ ref('people') }} \ No newline at end of file diff --git a/integration_tests/models/plugins/snowflake/snowflake_external.yml b/integration_tests/models/plugins/snowflake/snowflake_external.yml index 4e8c24b6..943ce535 100644 --- a/integration_tests/models/plugins/snowflake/snowflake_external.yml +++ b/integration_tests/models/plugins/snowflake/snowflake_external.yml @@ -20,9 +20,6 @@ sources: data_type: varchar(64) - name: email data_type: varchar(64) - - name: email - alias: email_alias - data_type: varchar(64) tests: &equal-to-the-people - dbt_utils.equality: compare_model: ref('people') @@ -31,7 +28,6 @@ sources: - first_name - last_name - email - - email_alias - name: people_csv_partitioned external: @@ -155,4 +151,26 @@ sources: tests: *equal-to-the-people columns: - name: id - description: "the unique ID for people" \ No newline at end of file + description: "the unique ID for people" + + # test for column aliasing + - name: people_csv_aliased + external: *csv-people + columns: + - name: id + data_type: int + - name: first_name + data_type: varchar(64) + - name: last_name + data_type: varchar(64) + - name: email + alias: email_alias + data_type: varchar(64) + tests: + - dbt_utils.equality: + compare_model: ref('people_alias') + compare_columns: + - id + - first_name + - last_name + - email_alias \ No newline at end of file