diff --git a/dbt/include/dremio/macros/adapters/snapshot.sql b/dbt/include/dremio/macros/adapters/snapshot.sql index 9c817b26..5a3bf949 100644 --- a/dbt/include/dremio/macros/adapters/snapshot.sql +++ b/dbt/include/dremio/macros/adapters/snapshot.sql @@ -14,22 +14,34 @@ limitations under the License.*/ {% macro dremio__snapshot_merge_sql(target, source, insert_cols) -%} + {%- set columns = config.get("snapshot_table_column_names") or get_snapshot_table_column_names() -%} {%- set insert_cols_csv = insert_cols | join(', ') -%} merge into {{ target }} as DBT_INTERNAL_DEST using {{ source }} as DBT_INTERNAL_SOURCE - on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id + on DBT_INTERNAL_SOURCE.{{ columns.dbt_scd_id }} = DBT_INTERNAL_DEST.{{ columns.dbt_scd_id }} when matched - then update - set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to + {%- if config.get("dbt_valid_to_current") %} + and ( + DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} = {{ config.get('dbt_valid_to_current') }} + or DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null + ) + {%- else %} + and DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null + {%- endif %} + and DBT_INTERNAL_SOURCE.dbt_change_type in ('update','delete') + then update + set {{ columns.dbt_valid_to }} = DBT_INTERNAL_SOURCE.{{ columns.dbt_valid_to }} when not matched - then insert ({{ insert_cols_csv }}) - values - ({% for column_name in insert_cols -%} - DBT_INTERNAL_SOURCE.{{ column_name }} - {%- if not loop.last %}, {%- endif %} - {%- endfor %}) - + and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert' + then insert ({{ insert_cols_csv }}) + values + ( + {%- for column_name in insert_cols -%} + DBT_INTERNAL_SOURCE.{{ column_name }}{% if not loop.last %}, {% endif %} + {%- endfor %} + ) +; {% endmacro %} \ No newline at end of file diff --git a/dev_requirements.txt b/dev_requirements.txt index d7ca81e6..d3052346 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -3,8 +3,8 @@ Babel==2.12.1 betterproto==1.2.5 certifi==2023.7.22 charset-normalizer==3.1.0 -dbt-core==1.8.8 -dbt-tests-adapter==1.8.0 +dbt-core==1.9.1 +dbt-tests-adapter==1.10.1 python-dotenv==1.0.1 exceptiongroup==1.1.1 future==0.18.3 diff --git a/setup.py b/setup.py index e2e1b4f3..d75216a8 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ package_name = "dbt-dremio" -package_version = "1.8.1" +package_version = "1.9.0" description = """The Dremio adapter plugin for dbt""" @@ -37,8 +37,9 @@ packages=find_namespace_packages(include=["dbt", "dbt.*"]), include_package_data=True, install_requires=[ - "dbt-core>=1.8", - "dbt-adapters>=1.0.0, <2.0.0", + "dbt-core>=1.9", + "dbt-common>=1.14.0,<2.0", + "dbt-adapters>=1.10.4,<2.0", "requests>=2.31.0", ], classifiers=[