Skip to content

Commit

Permalink
Remove customized snapshot_check_all_get_existing_columns macro (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeatty10 authored Feb 6, 2023
1 parent daf184b commit c1355a7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 75 deletions.
23 changes: 0 additions & 23 deletions dbt/include/mariadb/macros/materializations/snapshot/snapshot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -114,29 +114,6 @@

{% endmaterialization %}

{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}
{%- set query_columns = get_columns_in_query(node['compiled_sql']) -%}
{%- if not target_exists -%}
{# no table yet -> return whatever the query does #}
{{ return([false, query_columns]) }}
{%- endif -%}
{# handle any schema changes #}
{%- set target_table = node.get('alias', node.get('name')) -%}
{%- set target_relation = adapter.get_relation(database=None, schema=node.schema, identifier=target_table) -%}
{%- set existing_cols = get_columns_in_query('select * from ' ~ target_relation) -%}
{%- set ns = namespace() -%} {# handle for-loop scoping with a namespace #}
{%- set ns.column_added = false -%}

{%- set intersection = [] -%}
{%- for col in query_columns -%}
{%- if col in existing_cols -%}
{%- do intersection.append(col) -%}
{%- else -%}
{% set ns.column_added = true %}
{%- endif -%}
{%- endfor -%}
{{ return([ns.column_added, intersection]) }}
{%- endmacro %}

{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}

Expand Down
24 changes: 0 additions & 24 deletions dbt/include/mysql/macros/materializations/snapshot/snapshot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,3 @@
{{ return({'relations': [target_relation]}) }}

{% endmaterialization %}

{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}
{%- set query_columns = get_columns_in_query(node['compiled_sql']) -%}
{%- if not target_exists -%}
{# no table yet -> return whatever the query does #}
{{ return([false, query_columns]) }}
{%- endif -%}
{# handle any schema changes #}
{%- set target_table = node.get('alias', node.get('name')) -%}
{%- set target_relation = adapter.get_relation(database=None, schema=node.schema, identifier=target_table) -%}
{%- set existing_cols = get_columns_in_query('select * from ' ~ target_relation) -%}
{%- set ns = namespace() -%} {# handle for-loop scoping with a namespace #}
{%- set ns.column_added = false -%}

{%- set intersection = [] -%}
{%- for col in query_columns -%}
{%- if col in existing_cols -%}
{%- do intersection.append(col) -%}
{%- else -%}
{% set ns.column_added = true %}
{%- endif -%}
{%- endfor -%}
{{ return([ns.column_added, intersection]) }}
{%- endmacro %}
24 changes: 0 additions & 24 deletions dbt/include/mysql5/macros/materializations/snapshot/snapshot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -114,30 +114,6 @@

{% endmaterialization %}

{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}
{%- set query_columns = get_columns_in_query(node['compiled_sql']) -%}
{%- if not target_exists -%}
{# no table yet -> return whatever the query does #}
{{ return([false, query_columns]) }}
{%- endif -%}
{# handle any schema changes #}
{%- set target_table = node.get('alias', node.get('name')) -%}
{%- set target_relation = adapter.get_relation(database=None, schema=node.schema, identifier=target_table) -%}
{%- set existing_cols = get_columns_in_query('select * from ' ~ target_relation) -%}
{%- set ns = namespace() -%} {# handle for-loop scoping with a namespace #}
{%- set ns.column_added = false -%}

{%- set intersection = [] -%}
{%- for col in query_columns -%}
{%- if col in existing_cols -%}
{%- do intersection.append(col) -%}
{%- else -%}
{% set ns.column_added = true %}
{%- endif -%}
{%- endfor -%}
{{ return([ns.column_added, intersection]) }}
{%- endmacro %}

{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}

select
Expand Down
10 changes: 6 additions & 4 deletions tests/functional/adapter/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
from dbt.tests.adapter.basic.test_ephemeral import BaseEphemeral
from dbt.tests.adapter.basic.test_incremental import BaseIncremental
from dbt.tests.adapter.basic.test_generic_tests import BaseGenericTests
from dbt.tests.adapter.basic.test_snapshot_check_cols import BaseSnapshotCheckCols
from dbt.tests.adapter.basic.test_snapshot_timestamp import BaseSnapshotTimestamp
from dbt.tests.adapter.basic.test_snapshot_check_cols import (
BaseSnapshotCheckCols,
)
from dbt.tests.adapter.basic.test_snapshot_timestamp import (
BaseSnapshotTimestamp,
)
from dbt.tests.adapter.basic.test_adapter_methods import BaseAdapterMethod
from dbt.tests.util import run_dbt, check_relations_equal

Expand Down Expand Up @@ -47,8 +51,6 @@ class TestGenericTestsMySQL(BaseGenericTests):
pass


# TODO
@pytest.mark.skip(reason="known failure to fix")
class TestSnapshotCheckColsMySQL(BaseSnapshotCheckCols):
pass

Expand Down

0 comments on commit c1355a7

Please sign in to comment.