Skip to content

Commit

Permalink
Merge pull request #321 from dbt-labs/hotfix--fix-tests-for-#308
Browse files Browse the repository at this point in the history
[HOTFIX] fix tests for #308
  • Loading branch information
dataders authored Oct 28, 2024
2 parents 9e6b6c0 + f93ef17 commit 241cd44
Show file tree
Hide file tree
Showing 15 changed files with 386 additions and 10 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## dbt-external-tables v0.10.0

### Snowflake
* Refactor create_external_table.sql in snowflake plugin by @kyleburke-meq in https://github.com/dbt-labs/dbt-external-tables/pull/318
* stage_external_sources Comparing source_name of the node instead of the name of the node by @ward-resa in https://github.com/dbt-labs/dbt-external-tables/pull/312
* added ignore_case for Snowflake by @cakkinep in https://github.com/dbt-labs/dbt-external-tables/pull/308

## New Contributors
* @ward-resa made their first contribution in https://github.com/dbt-labs/dbt-external-tables/pull/312

**Full Changelog**: https://github.com/dbt-labs/dbt-external-tables/compare/0.9.0...0.10.0-b1

## dbt-external-tables v0.9.0

### Snowflake
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ sources:

- name: people_parquet_column_list_unpartitioned
external: &parquet-people
location: '@{{ target.schema }}.dbt_external_tables_testing/parquet'
location: '@{{ target.schema }}.dbt_external_tables_testing/parquet/'
file_format: '{{ target.schema }}.dbt_external_tables_testing_parquet'
columns: *cols-of-the-people
tests: *equal-to-the-people
Expand Down Expand Up @@ -206,11 +206,12 @@ sources:
- name: people_parquet_infer_schema_ignore_case_unpartitioned
external:
<<: *parquet-people
location: '@{{ target.schema }}.dbt_external_tables_testing/parquet_capitalized'
infer_schema: true
ignore_case: true
tests:
- dbt_utils.equality:
compare_model: ref('people_ignore_case')
compare_model: ref('people')
compare_columns:
- id
- first_name
Expand All @@ -220,12 +221,13 @@ sources:
- name: people_parquet_column_list_ignore_case_partitioned
external:
<<: *parquet-people
location: '@{{ target.schema }}.dbt_external_tables_testing/parquet_capitalized'
partitions: *parts-of-the-people
ignore_case: true
columns: *cols-of-the-people
tests:
- dbt_utils.equality:
compare_model: ref('people_ignore_case')
compare_model: ref('people')
compare_columns:
- id
- first_name
Expand Down
5 changes: 5 additions & 0 deletions integration_tests/package-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
packages:
- local: ../
- package: dbt-labs/dbt_utils
version: 1.3.0
sha1_hash: d412a8f2761befedebc730e6d5197956aec4fc9b
2 changes: 1 addition & 1 deletion integration_tests/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
packages:
- local: ../
- package: dbt-labs/dbt_utils
version: 0.8.0
version: 1.3.0
356 changes: 356 additions & 0 deletions integration_tests/public_data/capitalize_parquet.ipynb

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 7 additions & 2 deletions macros/plugins/snowflake/create_external_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
{%- set external = source_node.external -%}
{%- set partitions = external.partitions -%}
{%- set infer_schema = external.infer_schema -%}
{%- set ignore_case = external.ignore_case -%}
{%- set ignore_case = external.ignore_case or false -%}

{% if infer_schema %}
{% set query_infer_schema %}
select * from table( infer_schema( location=>'{{external.location}}', file_format=>'{{external.file_format}}', ignore_case=>true) )
select * from table( infer_schema( location=>'{{external.location}}', file_format=>'{{external.file_format}}', ignore_case=> {{ ignore_case }}) )
{% endset %}
{% if execute %}
{% set columns_infer = run_query(query_infer_schema) %}
Expand All @@ -19,6 +19,8 @@

{# https://docs.snowflake.net/manuals/sql-reference/sql/create-external-table.html #}
{# This assumes you have already created an external stage #}

{% set ddl %}
create or replace external table {{source(source_node.source_name, source_node.name)}}
{%- if columns or partitions or infer_schema -%}
(
Expand Down Expand Up @@ -83,4 +85,7 @@
{% if external.integration -%} integration = '{{external.integration}}' {%- endif %}
file_format = {{external.file_format}}
{% if external.table_format -%} table_format = '{{external.table_format}}' {%- endif %}
{% endset %}
{# {{ log('ddl: ' ~ ddl, info=True) }} #}
{{ ddl }};
{% endmacro %}

0 comments on commit 241cd44

Please sign in to comment.