dbt-adapters 1.16.0__py3-none-any.whl → 1.16.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dbt-adapters might be problematic. Click here for more details.

dbt/adapters/__about__.py CHANGED
@@ -1 +1 @@
1
- version = "1.16.0"
1
+ version = "1.16.2"
@@ -16,6 +16,13 @@
16
16
  {{ return(columns) }}
17
17
  {% endmacro %}
18
18
 
19
+ {%- macro get_list_of_column_names(columns) -%}
20
+ {% set col_names = [] %}
21
+ {% for col in columns %}
22
+ {% do col_names.append(col.name) %}
23
+ {% endfor %}
24
+ {{ return(col_names) }}
25
+ {% endmacro %}
19
26
 
20
27
  {% macro get_empty_subquery_sql(select_sql, select_sql_header=none) -%}
21
28
  {{ return(adapter.dispatch('get_empty_subquery_sql', 'dbt')(select_sql, select_sql_header)) }}
@@ -32,15 +32,15 @@
32
32
  {% endif %}
33
33
 
34
34
  -- as a general rule, data platforms that can clone tables can also do atomic 'create or replace'
35
- {% call statement('main') %}
36
- {% if target_relation and defer_relation and target_relation == defer_relation %}
37
- {{ log("Target relation and defer relation are the same, skipping clone for relation: " ~ target_relation.render()) }}
38
- {% else %}
39
- {{ create_or_replace_clone(target_relation, defer_relation) }}
40
- {% endif %}
41
-
42
- {% endcall %}
43
-
35
+ {% if target_relation.database == defer_relation.database and
36
+ target_relation.schema == defer_relation.schema and
37
+ target_relation.identifier == defer_relation.identifier %}
38
+ {{ log("Target relation and defer relation are the same, skipping clone for relation: " ~ target_relation.render()) }}
39
+ {% else %}
40
+ {% call statement('main') %}
41
+ {{ create_or_replace_clone(target_relation, defer_relation) }}
42
+ {% endcall %}
43
+ {% endif %}
44
44
  {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}
45
45
  {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}
46
46
  {% do persist_docs(target_relation, model) %}
@@ -8,7 +8,7 @@
8
8
  {% macro default__create_columns(relation, columns) %}
9
9
  {% for column in columns %}
10
10
  {% call statement() %}
11
- alter table {{ relation.render() }} add column "{{ column.name }}" {{ column.data_type }};
11
+ alter table {{ relation.render() }} add column {{ adapter.quote(column.name) }} {{ column.data_type }};
12
12
  {% endcall %}
13
13
  {% endfor %}
14
14
  {% endmacro %}
@@ -153,18 +153,35 @@
153
153
  left join deletes_source_data as source_data
154
154
  on {{ unique_key_join_on(strategy.unique_key, "snapshotted_data", "source_data") }}
155
155
  where {{ unique_key_is_null(strategy.unique_key, "source_data") }}
156
+
157
+ {%- if strategy.hard_deletes == 'new_record' %}
158
+ and not (
159
+ --avoid updating the record's valid_to if the latest entry is marked as deleted
160
+ snapshotted_data.{{ columns.dbt_is_deleted }} = 'True'
161
+ and snapshotted_data.{{ columns.dbt_valid_to }} is null
162
+ )
163
+ {%- endif %}
156
164
  )
157
165
  {%- endif %}
158
166
 
159
167
  {%- if strategy.hard_deletes == 'new_record' %}
168
+ {% set snapshotted_cols = get_list_of_column_names(get_columns_in_relation(target_relation)) %}
160
169
  {% set source_sql_cols = get_column_schema_from_query(source_sql) %}
161
170
  ,
162
171
  deletion_records as (
163
172
 
164
173
  select
165
174
  'insert' as dbt_change_type,
175
+ {#
176
+ If a column has been added to the source it won't yet exist in the
177
+ snapshotted table so we insert a null value as a placeholder for the column.
178
+ #}
166
179
  {%- for col in source_sql_cols -%}
180
+ {%- if col.name in snapshotted_cols -%}
167
181
  snapshotted_data.{{ adapter.quote(col.column) }},
182
+ {%- else -%}
183
+ NULL as {{ adapter.quote(col.column) }},
184
+ {%- endif -%}
168
185
  {% endfor -%}
169
186
  {%- if strategy.unique_key | is_list -%}
170
187
  {%- for key in strategy.unique_key -%}
@@ -182,6 +199,11 @@
182
199
  left join deletes_source_data as source_data
183
200
  on {{ unique_key_join_on(strategy.unique_key, "snapshotted_data", "source_data") }}
184
201
  where {{ unique_key_is_null(strategy.unique_key, "source_data") }}
202
+ and not (
203
+ --avoid inserting a new record if the latest one is marked as deleted
204
+ snapshotted_data.{{ columns.dbt_is_deleted }} = 'True'
205
+ and snapshotted_data.{{ columns.dbt_valid_to }} is null
206
+ )
185
207
 
186
208
  )
187
209
  {%- endif %}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dbt-adapters
3
- Version: 1.16.0
3
+ Version: 1.16.2
4
4
  Summary: The set of adapter protocols and base functionality that supports integration with dbt-core
5
5
  Project-URL: Homepage, https://github.com/dbt-labs/dbt-adapters/tree/main/dbt-adapters
6
6
  Project-URL: Documentation, https://docs.getdbt.com
@@ -1,4 +1,4 @@
1
- dbt/adapters/__about__.py,sha256=6EsnLejJWxuMqRt_s2lK0ter3lZGaIm5OK1MPeLZC5M,19
1
+ dbt/adapters/__about__.py,sha256=c-MIZMVgykYbxxmOCbsej1BWOTWk2v_x-ATUDJhCXjM,19
2
2
  dbt/adapters/__init__.py,sha256=3noHsg-64qI0_Pw6OR9F7l1vU2_qrJvinq8POTtuaZM,252
3
3
  dbt/adapters/cache.py,sha256=WGy4ewnz-J13LverTACBW2iFhGswrWLgm-wiBrQnMzo,20084
4
4
  dbt/adapters/capability.py,sha256=M3FkC9veKnNB7a7uQyl7EHX_AGNXPChbHAkcY4cgXCY,2534
@@ -64,7 +64,7 @@ dbt/include/global_project/__init__.py,sha256=-0HL5OkeJSrxglm1Y-UltTiBPY2BbWx8Zp
64
64
  dbt/include/global_project/dbt_project.yml,sha256=RTtOhnBpEL0gbd1GlpxuVr6eZJBPvgWfNw-F88sKQ-w,109
65
65
  dbt/include/global_project/docs/overview.md,sha256=VuObM4pcS-TvwYeAjjUbe0TBhEnxf6g30EPWrGjya_w,1824
66
66
  dbt/include/global_project/macros/adapters/apply_grants.sql,sha256=3NUJLWmNE0ZAWxc1LuIpo6-dTfLEBjX1Os5BdDb_IOQ,6861
67
- dbt/include/global_project/macros/adapters/columns.sql,sha256=21cb0Q8A3oDbajV7oL06arDcmg-YuvWRmQ-07KeI-dk,5483
67
+ dbt/include/global_project/macros/adapters/columns.sql,sha256=VfTQX1DYofa9KvEwcFHHSUHkqGknFZl264T_8d6GnWQ,5681
68
68
  dbt/include/global_project/macros/adapters/freshness.sql,sha256=bl2Kn7s2pDMzrJWeLXYyUVYXDmloLxntjOgyWSDcgCs,1200
69
69
  dbt/include/global_project/macros/adapters/indexes.sql,sha256=DasPn32Cm0OZyjBPBWzL4BpK9PZ3xF_Pu8Nh4NgASaw,1366
70
70
  dbt/include/global_project/macros/adapters/metadata.sql,sha256=meNIc3z4lXdh1lDb-K1utKb8VzAVuN23E6XWgMZGDhQ,3512
@@ -89,7 +89,7 @@ dbt/include/global_project/macros/materializations/models/materialized_view.sql,
89
89
  dbt/include/global_project/macros/materializations/models/table.sql,sha256=F9ogmZofhPdzKwhhFJ_GfI5QRXQxLjTl6xTiCgulQ9g,2682
90
90
  dbt/include/global_project/macros/materializations/models/view.sql,sha256=LPqM3aTsWiAalFz322aTpqKqCdl4hxN8ubcwXZIIDDw,3249
91
91
  dbt/include/global_project/macros/materializations/models/clone/can_clone_table.sql,sha256=YVq2f574IxMDuEv5rbaTvUpLLqc-jQfyOgBQJQGWcmk,187
92
- dbt/include/global_project/macros/materializations/models/clone/clone.sql,sha256=X85U0zwq_OINxeZ7JDer9i3BgQZvgGM-tKTvITrQx5s,2716
92
+ dbt/include/global_project/macros/materializations/models/clone/clone.sql,sha256=hd6AFfjtVWqq10okMnCeBCnRxid0PvY7prIYFA7Wt44,2813
93
93
  dbt/include/global_project/macros/materializations/models/clone/create_or_replace_clone.sql,sha256=qr33DwFOpRG0wGVsGvr63-MexYMNZC9xKdGOPmICp_c,367
94
94
  dbt/include/global_project/macros/materializations/models/incremental/column_helpers.sql,sha256=hslQlGKW0oW97srfugsFVRR-L6RrzRcnwr3uLhzI0X4,2577
95
95
  dbt/include/global_project/macros/materializations/models/incremental/incremental.sql,sha256=yOG-Rsv_j6JhGIHdfFk77_DoILFgFqsLN27R5LdCnZM,4546
@@ -99,7 +99,7 @@ dbt/include/global_project/macros/materializations/models/incremental/on_schema_
99
99
  dbt/include/global_project/macros/materializations/models/incremental/strategies.sql,sha256=ORGWiYfj-b3_VIps9FDlyx-Q4A2hZzX2aYLocW8b6pU,2613
100
100
  dbt/include/global_project/macros/materializations/seeds/helpers.sql,sha256=Y15ej-D3gm1ExIOMNT208q43gRk8d985WQBuGSooNL0,3920
101
101
  dbt/include/global_project/macros/materializations/seeds/seed.sql,sha256=YSoGzVO3iIUiOKIUM9G7yApGLFH4O9bv_d4KjHo3p4Q,2155
102
- dbt/include/global_project/macros/materializations/snapshots/helpers.sql,sha256=Ox-7PZ9NHleqRdzTv7MWP0pgOByQujNCS0xQaBXtndU,11378
102
+ dbt/include/global_project/macros/materializations/snapshots/helpers.sql,sha256=EdKKm0_uEot5msQbs77iFdTJh-HmuV8hgTLVDT3MNo0,12468
103
103
  dbt/include/global_project/macros/materializations/snapshots/snapshot.sql,sha256=clIZtCE7vvOXxzz1t2KlmPZM7AuSGsK7MInspo0N5Qg,4043
104
104
  dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql,sha256=WaGQCuv4o_qxBw7b2KQvUnSg0UkPklwAQHK1-QngN_M,1369
105
105
  dbt/include/global_project/macros/materializations/snapshots/strategies.sql,sha256=AfIsRiw0YnQym5wUiWR2JpiEEky4_WBTpTtE0HJvpZw,6928
@@ -163,7 +163,7 @@ dbt/include/global_project/macros/utils/right.sql,sha256=EwNG98CAFIwNDmarwopf7Rk
163
163
  dbt/include/global_project/macros/utils/safe_cast.sql,sha256=1mswwkDACmIi1I99JKb_-vq3kjMe4HhMRV70mW8Bt4Y,298
164
164
  dbt/include/global_project/macros/utils/split_part.sql,sha256=fXEIS0oIiYR7-4lYbb0QbZdG-q2TpV63AFd1ky4I5UM,714
165
165
  dbt/include/global_project/tests/generic/builtin.sql,sha256=p94xdyPwb2TlxgLBqCfrcRfJ1QNgsjPvBm8f0Q5eqZM,1022
166
- dbt_adapters-1.16.0.dist-info/METADATA,sha256=KjCmvYSjB_XigcdfmkJlzPVEHzwAlV17OGPM4mJa9Wo,4534
167
- dbt_adapters-1.16.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
168
- dbt_adapters-1.16.0.dist-info/licenses/LICENSE,sha256=9yjigiJhWcCZvQjdagGKDwrRph58QWc5P2bVSQwXo6s,11344
169
- dbt_adapters-1.16.0.dist-info/RECORD,,
166
+ dbt_adapters-1.16.2.dist-info/METADATA,sha256=Ki0CCudw4-r-lS7Gpe7ipKSlX-AWhib0PX7e8Wl2RCc,4534
167
+ dbt_adapters-1.16.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
168
+ dbt_adapters-1.16.2.dist-info/licenses/LICENSE,sha256=9yjigiJhWcCZvQjdagGKDwrRph58QWc5P2bVSQwXo6s,11344
169
+ dbt_adapters-1.16.2.dist-info/RECORD,,