Skip to content

Commit

Permalink
Merge pull request #43 from elementary-data/schema_snapshots_fix
Browse files Browse the repository at this point in the history
Schema snapshots fix
  • Loading branch information
elongl authored Jul 6, 2022
2 parents db1a95d + 0c6da15 commit 24f6ed1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@ columns_snapshot as (

{% if is_incremental() %}
{%- set known_columns_query %}
(
select full_column_name from {{ this }}
where detected_at = (select max(detected_at) from {{ this }})
)
{% endset %}
{%- set known_columns = elementary.result_column_to_list(known_columns_query) %}

{%- set known_tables_query %}
(
select distinct full_table_name from {{ this }}
where detected_at = (select max(detected_at) from {{ this }})
)
{% endset %}
{%- set known_tables = elementary.result_column_to_list(known_tables_query) %}

case when
{{ elementary.full_column_name() }} not in {{ elementary.strings_list_to_tuple(known_columns) }}
and full_table_name in {{ elementary.strings_list_to_tuple(known_tables) }}
{{ elementary.full_column_name() }} not in {{ known_columns_query }}
and full_table_name in {{ known_tables_query }}
then true
else false end
as is_new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@ schema_tables as (

{% if is_incremental() %}
{%- set known_tables_query %}
(
select full_table_name from {{ this }}
where detected_at = (select max(detected_at) from {{ this }})
)
{% endset %}
{%- set known_tables = elementary.result_column_to_list(known_tables_query) %}

{%- set known_schemas_query %}
(
select distinct full_schema_name from {{ this }}
where detected_at = (select max(detected_at) from {{ this }})
)
{% endset %}
{%- set known_schemas = elementary.result_column_to_list(known_schemas_query) %}

case when
full_table_name not in {{ elementary.strings_list_to_tuple(known_tables) }}
and full_schema_name in {{ elementary.strings_list_to_tuple(known_schemas) }}
full_table_name not in {{ known_tables_query }}
and full_schema_name in {{ known_schemas_query }}
then true
else false end
as is_new
Expand Down

0 comments on commit 24f6ed1

Please sign in to comment.