dbt-adapters 1.6.1__py3-none-any.whl → 1.7.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 +1 -1
- dbt/adapters/base/impl.py +8 -12
- dbt/adapters/base/relation.py +11 -0
- dbt/adapters/exceptions/compilation.py +4 -2
- dbt/include/global_project/macros/materializations/models/incremental/incremental.sql +3 -2
- dbt/include/global_project/macros/materializations/snapshots/helpers.sql +92 -39
- dbt/include/global_project/macros/materializations/snapshots/snapshot.sql +16 -11
- dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql +10 -3
- dbt/include/global_project/macros/materializations/snapshots/strategies.sql +18 -12
- {dbt_adapters-1.6.1.dist-info → dbt_adapters-1.7.2.dist-info}/METADATA +3 -4
- {dbt_adapters-1.6.1.dist-info → dbt_adapters-1.7.2.dist-info}/RECORD +13 -13
- {dbt_adapters-1.6.1.dist-info → dbt_adapters-1.7.2.dist-info}/WHEEL +0 -0
- {dbt_adapters-1.6.1.dist-info → dbt_adapters-1.7.2.dist-info}/licenses/LICENSE +0 -0
dbt/adapters/__about__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
version = "1.
|
|
1
|
+
version = "1.7.2"
|
dbt/adapters/base/impl.py
CHANGED
|
@@ -83,7 +83,6 @@ from dbt.adapters.exceptions import (
|
|
|
83
83
|
QuoteConfigTypeError,
|
|
84
84
|
RelationReturnedMultipleResultsError,
|
|
85
85
|
RenameToNoneAttemptedError,
|
|
86
|
-
SnapshotTargetIncompleteError,
|
|
87
86
|
SnapshotTargetNotSnapshotTableError,
|
|
88
87
|
UnexpectedNonTimestampError,
|
|
89
88
|
)
|
|
@@ -764,7 +763,9 @@ class BaseAdapter(metaclass=AdapterMeta):
|
|
|
764
763
|
return [col for (col_name, col) in from_columns.items() if col_name in missing_columns]
|
|
765
764
|
|
|
766
765
|
@available.parse_none
|
|
767
|
-
def valid_snapshot_target(
|
|
766
|
+
def valid_snapshot_target(
|
|
767
|
+
self, relation: BaseRelation, column_names: Optional[Dict[str, str]] = None
|
|
768
|
+
) -> None:
|
|
768
769
|
"""Ensure that the target relation is valid, by making sure it has the
|
|
769
770
|
expected columns.
|
|
770
771
|
|
|
@@ -782,21 +783,16 @@ class BaseAdapter(metaclass=AdapterMeta):
|
|
|
782
783
|
|
|
783
784
|
columns = self.get_columns_in_relation(relation)
|
|
784
785
|
names = set(c.name.lower() for c in columns)
|
|
785
|
-
expanded_keys = ("scd_id", "valid_from", "valid_to")
|
|
786
|
-
extra = []
|
|
787
786
|
missing = []
|
|
788
|
-
|
|
789
|
-
|
|
787
|
+
# Note: we're not checking dbt_updated_at here because it's not
|
|
788
|
+
# always present.
|
|
789
|
+
for column in ("dbt_scd_id", "dbt_valid_from", "dbt_valid_to"):
|
|
790
|
+
desired = column_names[column] if column_names else column
|
|
790
791
|
if desired not in names:
|
|
791
792
|
missing.append(desired)
|
|
792
|
-
if legacy in names:
|
|
793
|
-
extra.append(legacy)
|
|
794
793
|
|
|
795
794
|
if missing:
|
|
796
|
-
|
|
797
|
-
raise SnapshotTargetIncompleteError(extra, missing)
|
|
798
|
-
else:
|
|
799
|
-
raise SnapshotTargetNotSnapshotTableError(missing)
|
|
795
|
+
raise SnapshotTargetNotSnapshotTableError(missing)
|
|
800
796
|
|
|
801
797
|
@available.parse_none
|
|
802
798
|
def expand_target_column_types(
|
dbt/adapters/base/relation.py
CHANGED
|
@@ -6,6 +6,7 @@ from typing import (
|
|
|
6
6
|
Dict,
|
|
7
7
|
FrozenSet,
|
|
8
8
|
Iterator,
|
|
9
|
+
List,
|
|
9
10
|
Optional,
|
|
10
11
|
Set,
|
|
11
12
|
Tuple,
|
|
@@ -341,6 +342,16 @@ class BaseRelation(FakeAPIObject, Hashable):
|
|
|
341
342
|
)
|
|
342
343
|
return cls.from_dict(kwargs)
|
|
343
344
|
|
|
345
|
+
@classmethod
|
|
346
|
+
def scd_args(cls: Type[Self], primary_key: Union[str, List[str]], updated_at) -> List[str]:
|
|
347
|
+
scd_args = []
|
|
348
|
+
if isinstance(primary_key, list):
|
|
349
|
+
scd_args.extend(primary_key)
|
|
350
|
+
else:
|
|
351
|
+
scd_args.append(primary_key)
|
|
352
|
+
scd_args.append(updated_at)
|
|
353
|
+
return scd_args
|
|
354
|
+
|
|
344
355
|
@property
|
|
345
356
|
def can_be_renamed(self) -> bool:
|
|
346
357
|
return self.type in self.renameable_relations
|
|
@@ -150,8 +150,10 @@ class SnapshotTargetNotSnapshotTableError(CompilationError):
|
|
|
150
150
|
super().__init__(msg=self.get_message())
|
|
151
151
|
|
|
152
152
|
def get_message(self) -> str:
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
missing = '", "'.join(self.missing)
|
|
154
|
+
msg = (
|
|
155
|
+
f'Snapshot target is missing configured columns (missing "{missing}"). '
|
|
156
|
+
"See https://docs.getdbt.com/docs/build/snapshots#snapshot-meta-fields for more information."
|
|
155
157
|
)
|
|
156
158
|
return msg
|
|
157
159
|
|
|
@@ -32,6 +32,9 @@
|
|
|
32
32
|
|
|
33
33
|
{% set to_drop = [] %}
|
|
34
34
|
|
|
35
|
+
{% set incremental_strategy = config.get('incremental_strategy') or 'default' %}
|
|
36
|
+
{% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}
|
|
37
|
+
|
|
35
38
|
{% if existing_relation is none %}
|
|
36
39
|
{% set build_sql = get_create_table_as_sql(False, target_relation, sql) %}
|
|
37
40
|
{% elif full_refresh_mode %}
|
|
@@ -52,9 +55,7 @@
|
|
|
52
55
|
{% endif %}
|
|
53
56
|
|
|
54
57
|
{#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}
|
|
55
|
-
{% set incremental_strategy = config.get('incremental_strategy') or 'default' %}
|
|
56
58
|
{% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}
|
|
57
|
-
{% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}
|
|
58
59
|
{% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': temp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'incremental_predicates': incremental_predicates }) %}
|
|
59
60
|
{% set build_sql = strategy_sql_macro_func(strategy_arg_dict) %}
|
|
60
61
|
|
|
@@ -34,7 +34,12 @@
|
|
|
34
34
|
{{ adapter.dispatch('snapshot_staging_table', 'dbt')(strategy, source_sql, target_relation) }}
|
|
35
35
|
{% endmacro %}
|
|
36
36
|
|
|
37
|
+
{% macro get_snapshot_table_column_names() %}
|
|
38
|
+
{{ return({'dbt_valid_to': 'dbt_valid_to', 'dbt_valid_from': 'dbt_valid_from', 'dbt_scd_id': 'dbt_scd_id', 'dbt_updated_at': 'dbt_updated_at'}) }}
|
|
39
|
+
{% endmacro %}
|
|
40
|
+
|
|
37
41
|
{% macro default__snapshot_staging_table(strategy, source_sql, target_relation) -%}
|
|
42
|
+
{% set columns = config.get('snapshot_table_column_names') or get_snapshot_table_column_names() %}
|
|
38
43
|
|
|
39
44
|
with snapshot_query as (
|
|
40
45
|
|
|
@@ -44,35 +49,35 @@
|
|
|
44
49
|
|
|
45
50
|
snapshotted_data as (
|
|
46
51
|
|
|
47
|
-
select *,
|
|
48
|
-
{{ strategy.unique_key }} as dbt_unique_key
|
|
49
|
-
|
|
52
|
+
select *, {{ unique_key_fields(strategy.unique_key) }}
|
|
50
53
|
from {{ target_relation }}
|
|
51
|
-
where
|
|
54
|
+
where
|
|
55
|
+
{% if config.get('dbt_valid_to_current') %}
|
|
56
|
+
{# Check for either dbt_valid_to_current OR null, in order to correctly update records with nulls #}
|
|
57
|
+
( {{ columns.dbt_valid_to }} = {{ config.get('dbt_valid_to_current') }} or {{ columns.dbt_valid_to }} is null)
|
|
58
|
+
{% else %}
|
|
59
|
+
{{ columns.dbt_valid_to }} is null
|
|
60
|
+
{% endif %}
|
|
52
61
|
|
|
53
62
|
),
|
|
54
63
|
|
|
55
64
|
insertions_source_data as (
|
|
56
65
|
|
|
57
|
-
select
|
|
58
|
-
|
|
59
|
-
{{ strategy.
|
|
60
|
-
{{ strategy
|
|
61
|
-
{{ strategy.
|
|
62
|
-
nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to,
|
|
63
|
-
{{ strategy.scd_id }} as dbt_scd_id
|
|
66
|
+
select *, {{ unique_key_fields(strategy.unique_key) }},
|
|
67
|
+
{{ strategy.updated_at }} as {{ columns.dbt_updated_at }},
|
|
68
|
+
{{ strategy.updated_at }} as {{ columns.dbt_valid_from }},
|
|
69
|
+
{{ get_dbt_valid_to_current(strategy, columns) }},
|
|
70
|
+
{{ strategy.scd_id }} as {{ columns.dbt_scd_id }}
|
|
64
71
|
|
|
65
72
|
from snapshot_query
|
|
66
73
|
),
|
|
67
74
|
|
|
68
75
|
updates_source_data as (
|
|
69
76
|
|
|
70
|
-
select
|
|
71
|
-
|
|
72
|
-
{{ strategy.
|
|
73
|
-
{{ strategy.updated_at }} as
|
|
74
|
-
{{ strategy.updated_at }} as dbt_valid_from,
|
|
75
|
-
{{ strategy.updated_at }} as dbt_valid_to
|
|
77
|
+
select *, {{ unique_key_fields(strategy.unique_key) }},
|
|
78
|
+
{{ strategy.updated_at }} as {{ columns.dbt_updated_at }},
|
|
79
|
+
{{ strategy.updated_at }} as {{ columns.dbt_valid_from }},
|
|
80
|
+
{{ strategy.updated_at }} as {{ columns.dbt_valid_to }}
|
|
76
81
|
|
|
77
82
|
from snapshot_query
|
|
78
83
|
),
|
|
@@ -81,9 +86,7 @@
|
|
|
81
86
|
|
|
82
87
|
deletes_source_data as (
|
|
83
88
|
|
|
84
|
-
select
|
|
85
|
-
*,
|
|
86
|
-
{{ strategy.unique_key }} as dbt_unique_key
|
|
89
|
+
select *, {{ unique_key_fields(strategy.unique_key) }}
|
|
87
90
|
from snapshot_query
|
|
88
91
|
),
|
|
89
92
|
{% endif %}
|
|
@@ -95,13 +98,11 @@
|
|
|
95
98
|
source_data.*
|
|
96
99
|
|
|
97
100
|
from insertions_source_data as source_data
|
|
98
|
-
left outer join snapshotted_data
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
{{ strategy.row_changed }}
|
|
104
|
-
)
|
|
101
|
+
left outer join snapshotted_data
|
|
102
|
+
on {{ unique_key_join_on(strategy.unique_key, "snapshotted_data", "source_data") }}
|
|
103
|
+
where {{ unique_key_is_null(strategy.unique_key, "snapshotted_data") }}
|
|
104
|
+
or ({{ unique_key_is_not_null(strategy.unique_key, "snapshotted_data") }} and ({{ strategy.row_changed }})
|
|
105
|
+
|
|
105
106
|
)
|
|
106
107
|
|
|
107
108
|
),
|
|
@@ -111,10 +112,11 @@
|
|
|
111
112
|
select
|
|
112
113
|
'update' as dbt_change_type,
|
|
113
114
|
source_data.*,
|
|
114
|
-
snapshotted_data.dbt_scd_id
|
|
115
|
+
snapshotted_data.{{ columns.dbt_scd_id }}
|
|
115
116
|
|
|
116
117
|
from updates_source_data as source_data
|
|
117
|
-
join snapshotted_data
|
|
118
|
+
join snapshotted_data
|
|
119
|
+
on {{ unique_key_join_on(strategy.unique_key, "snapshotted_data", "source_data") }}
|
|
118
120
|
where (
|
|
119
121
|
{{ strategy.row_changed }}
|
|
120
122
|
)
|
|
@@ -128,14 +130,15 @@
|
|
|
128
130
|
select
|
|
129
131
|
'delete' as dbt_change_type,
|
|
130
132
|
source_data.*,
|
|
131
|
-
{{ snapshot_get_time() }} as dbt_valid_from,
|
|
132
|
-
{{ snapshot_get_time() }} as dbt_updated_at,
|
|
133
|
-
{{ snapshot_get_time() }} as dbt_valid_to,
|
|
134
|
-
snapshotted_data.dbt_scd_id
|
|
133
|
+
{{ snapshot_get_time() }} as {{ columns.dbt_valid_from }},
|
|
134
|
+
{{ snapshot_get_time() }} as {{ columns.dbt_updated_at }},
|
|
135
|
+
{{ snapshot_get_time() }} as {{ columns.dbt_valid_to }},
|
|
136
|
+
snapshotted_data.{{ columns.dbt_scd_id }}
|
|
135
137
|
|
|
136
138
|
from snapshotted_data
|
|
137
|
-
left join deletes_source_data as source_data
|
|
138
|
-
|
|
139
|
+
left join deletes_source_data as source_data
|
|
140
|
+
on {{ unique_key_join_on(strategy.unique_key, "snapshotted_data", "source_data") }}
|
|
141
|
+
where {{ unique_key_is_null(strategy.unique_key, "source_data") }}
|
|
139
142
|
)
|
|
140
143
|
{%- endif %}
|
|
141
144
|
|
|
@@ -155,12 +158,13 @@
|
|
|
155
158
|
{% endmacro %}
|
|
156
159
|
|
|
157
160
|
{% macro default__build_snapshot_table(strategy, sql) %}
|
|
161
|
+
{% set columns = config.get('snapshot_table_column_names') or get_snapshot_table_column_names() %}
|
|
158
162
|
|
|
159
163
|
select *,
|
|
160
|
-
{{ strategy.scd_id }} as dbt_scd_id,
|
|
161
|
-
{{ strategy.updated_at }} as dbt_updated_at,
|
|
162
|
-
{{ strategy.updated_at }} as dbt_valid_from,
|
|
163
|
-
|
|
164
|
+
{{ strategy.scd_id }} as {{ columns.dbt_scd_id }},
|
|
165
|
+
{{ strategy.updated_at }} as {{ columns.dbt_updated_at }},
|
|
166
|
+
{{ strategy.updated_at }} as {{ columns.dbt_valid_from }},
|
|
167
|
+
{{ get_dbt_valid_to_current(strategy, columns) }}
|
|
164
168
|
from (
|
|
165
169
|
{{ sql }}
|
|
166
170
|
) sbq
|
|
@@ -204,3 +208,52 @@
|
|
|
204
208
|
{% endif %}
|
|
205
209
|
{% endif %}
|
|
206
210
|
{% endmacro %}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
{% macro get_dbt_valid_to_current(strategy, columns) %}
|
|
214
|
+
{% set dbt_valid_to_current = config.get('dbt_valid_to_current') or "null" %}
|
|
215
|
+
coalesce(nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}), {{dbt_valid_to_current}})
|
|
216
|
+
as {{ columns.dbt_valid_to }}
|
|
217
|
+
{% endmacro %}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
{% macro unique_key_fields(unique_key) %}
|
|
221
|
+
{% if unique_key | is_list %}
|
|
222
|
+
{% for key in unique_key %}
|
|
223
|
+
{{ key }} as dbt_unique_key_{{ loop.index }}
|
|
224
|
+
{%- if not loop.last %} , {%- endif %}
|
|
225
|
+
{% endfor %}
|
|
226
|
+
{% else %}
|
|
227
|
+
{{ unique_key }} as dbt_unique_key
|
|
228
|
+
{% endif %}
|
|
229
|
+
{% endmacro %}
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
{% macro unique_key_join_on(unique_key, identifier, from_identifier) %}
|
|
233
|
+
{% if unique_key | is_list %}
|
|
234
|
+
{% for key in unique_key %}
|
|
235
|
+
{{ identifier }}.dbt_unique_key_{{ loop.index }} = {{ from_identifier }}.dbt_unique_key_{{ loop.index }}
|
|
236
|
+
{%- if not loop.last %} and {%- endif %}
|
|
237
|
+
{% endfor %}
|
|
238
|
+
{% else %}
|
|
239
|
+
{{ identifier }}.dbt_unique_key = {{ from_identifier }}.dbt_unique_key
|
|
240
|
+
{% endif %}
|
|
241
|
+
{% endmacro %}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
{% macro unique_key_is_null(unique_key, identifier) %}
|
|
245
|
+
{% if unique_key | is_list %}
|
|
246
|
+
{{ identifier }}.dbt_unique_key_1 is null
|
|
247
|
+
{% else %}
|
|
248
|
+
{{ identifier }}.dbt_unique_key is null
|
|
249
|
+
{% endif %}
|
|
250
|
+
{% endmacro %}
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
{% macro unique_key_is_not_null(unique_key, identifier) %}
|
|
254
|
+
{% if unique_key | is_list %}
|
|
255
|
+
{{ identifier }}.dbt_unique_key_1 is not null
|
|
256
|
+
{% else %}
|
|
257
|
+
{{ identifier }}.dbt_unique_key is not null
|
|
258
|
+
{% endif %}
|
|
259
|
+
{% endmacro %}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
{% materialization snapshot, default %}
|
|
2
|
-
{%- set config = model['config'] -%}
|
|
3
2
|
|
|
4
3
|
{%- set target_table = model.get('alias', model.get('name')) -%}
|
|
5
4
|
|
|
@@ -24,7 +23,9 @@
|
|
|
24
23
|
{{ run_hooks(pre_hooks, inside_transaction=True) }}
|
|
25
24
|
|
|
26
25
|
{% set strategy_macro = strategy_dispatch(strategy_name) %}
|
|
27
|
-
{
|
|
26
|
+
{# The model['config'] parameter below is no longer used, but passing anyway for compatibility #}
|
|
27
|
+
{# It was a dictionary of config, instead of the config object from the context #}
|
|
28
|
+
{% set strategy = strategy_macro(model, "snapshotted_data", "source_data", model['config'], target_relation_exists) %}
|
|
28
29
|
|
|
29
30
|
{% if not target_relation_exists %}
|
|
30
31
|
|
|
@@ -34,7 +35,9 @@
|
|
|
34
35
|
|
|
35
36
|
{% else %}
|
|
36
37
|
|
|
37
|
-
{
|
|
38
|
+
{% set columns = config.get("snapshot_table_column_names") or get_snapshot_table_column_names() %}
|
|
39
|
+
|
|
40
|
+
{{ adapter.valid_snapshot_target(target_relation, columns) }}
|
|
38
41
|
|
|
39
42
|
{% set build_or_select_sql = snapshot_staging_table(strategy, sql, target_relation) %}
|
|
40
43
|
{% set staging_table = build_snapshot_staging_table(strategy, sql, target_relation) %}
|
|
@@ -43,20 +46,22 @@
|
|
|
43
46
|
{% do adapter.expand_target_column_types(from_relation=staging_table,
|
|
44
47
|
to_relation=target_relation) %}
|
|
45
48
|
|
|
49
|
+
{% set remove_columns = ['dbt_change_type', 'DBT_CHANGE_TYPE', 'dbt_unique_key', 'DBT_UNIQUE_KEY'] %}
|
|
50
|
+
{% if unique_key | is_list %}
|
|
51
|
+
{% for key in strategy.unique_key %}
|
|
52
|
+
{{ remove_columns.append('dbt_unique_key_' + loop.index|string) }}
|
|
53
|
+
{{ remove_columns.append('DBT_UNIQUE_KEY_' + loop.index|string) }}
|
|
54
|
+
{% endfor %}
|
|
55
|
+
{% endif %}
|
|
56
|
+
|
|
46
57
|
{% set missing_columns = adapter.get_missing_columns(staging_table, target_relation)
|
|
47
|
-
| rejectattr('name', '
|
|
48
|
-
| rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')
|
|
49
|
-
| rejectattr('name', 'equalto', 'dbt_unique_key')
|
|
50
|
-
| rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')
|
|
58
|
+
| rejectattr('name', 'in', remove_columns)
|
|
51
59
|
| list %}
|
|
52
60
|
|
|
53
61
|
{% do create_columns(target_relation, missing_columns) %}
|
|
54
62
|
|
|
55
63
|
{% set source_columns = adapter.get_columns_in_relation(staging_table)
|
|
56
|
-
| rejectattr('name', '
|
|
57
|
-
| rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')
|
|
58
|
-
| rejectattr('name', 'equalto', 'dbt_unique_key')
|
|
59
|
-
| rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')
|
|
64
|
+
| rejectattr('name', 'in', remove_columns)
|
|
60
65
|
| list %}
|
|
61
66
|
|
|
62
67
|
{% set quoted_source_columns = [] %}
|
|
@@ -7,15 +7,22 @@
|
|
|
7
7
|
{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}
|
|
8
8
|
{%- set insert_cols_csv = insert_cols | join(', ') -%}
|
|
9
9
|
|
|
10
|
+
{%- set columns = config.get("snapshot_table_column_names") or get_snapshot_table_column_names() -%}
|
|
11
|
+
|
|
10
12
|
merge into {{ target.render() }} as DBT_INTERNAL_DEST
|
|
11
13
|
using {{ source }} as DBT_INTERNAL_SOURCE
|
|
12
|
-
on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id
|
|
14
|
+
on DBT_INTERNAL_SOURCE.{{ columns.dbt_scd_id }} = DBT_INTERNAL_DEST.{{ columns.dbt_scd_id }}
|
|
13
15
|
|
|
14
16
|
when matched
|
|
15
|
-
|
|
17
|
+
{% if config.get("dbt_valid_to_current") %}
|
|
18
|
+
and (DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} = {{ config.get('dbt_valid_to_current') }} or
|
|
19
|
+
DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null)
|
|
20
|
+
{% else %}
|
|
21
|
+
and DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null
|
|
22
|
+
{% endif %}
|
|
16
23
|
and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')
|
|
17
24
|
then update
|
|
18
|
-
set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to
|
|
25
|
+
set {{ columns.dbt_valid_to }} = DBT_INTERNAL_SOURCE.{{ columns.dbt_valid_to }}
|
|
19
26
|
|
|
20
27
|
when not matched
|
|
21
28
|
and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'
|
|
@@ -49,10 +49,13 @@
|
|
|
49
49
|
{#
|
|
50
50
|
Core strategy definitions
|
|
51
51
|
#}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
{% set
|
|
52
|
+
|
|
53
|
+
{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, model_config, target_exists) %}
|
|
54
|
+
{# The model_config parameter is no longer used, but is passed in anyway for compatibility. #}
|
|
55
|
+
{% set primary_key = config.get('unique_key') %}
|
|
56
|
+
{% set updated_at = config.get('updated_at') %}
|
|
57
|
+
{% set invalidate_hard_deletes = config.get('invalidate_hard_deletes') or false %}
|
|
58
|
+
{% set columns = config.get("snapshot_table_column_names") or get_snapshot_table_column_names() %}
|
|
56
59
|
|
|
57
60
|
{#/*
|
|
58
61
|
The snapshot relation might not have an {{ updated_at }} value if the
|
|
@@ -64,10 +67,11 @@
|
|
|
64
67
|
See https://github.com/dbt-labs/dbt-core/issues/2350
|
|
65
68
|
*/ #}
|
|
66
69
|
{% set row_changed_expr -%}
|
|
67
|
-
({{ snapshotted_rel }}.dbt_valid_from < {{ current_rel }}.{{ updated_at }})
|
|
70
|
+
({{ snapshotted_rel }}.{{ columns.dbt_valid_from }} < {{ current_rel }}.{{ updated_at }})
|
|
68
71
|
{%- endset %}
|
|
69
72
|
|
|
70
|
-
{% set
|
|
73
|
+
{% set scd_args = api.Relation.scd_args(primary_key, updated_at) %}
|
|
74
|
+
{% set scd_id_expr = snapshot_hash_arguments(scd_args) %}
|
|
71
75
|
|
|
72
76
|
{% do return({
|
|
73
77
|
"unique_key": primary_key,
|
|
@@ -133,11 +137,12 @@
|
|
|
133
137
|
{%- endmacro %}
|
|
134
138
|
|
|
135
139
|
|
|
136
|
-
{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel,
|
|
137
|
-
{
|
|
138
|
-
{% set
|
|
139
|
-
{% set
|
|
140
|
-
{% set
|
|
140
|
+
{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, model_config, target_exists) %}
|
|
141
|
+
{# The model_config parameter is no longer used, but is passed in anyway for compatibility. #}
|
|
142
|
+
{% set check_cols_config = config.get('check_cols') %}
|
|
143
|
+
{% set primary_key = config.get('unique_key') %}
|
|
144
|
+
{% set invalidate_hard_deletes = config.get('invalidate_hard_deletes') or false %}
|
|
145
|
+
{% set updated_at = config.get('updated_at') or snapshot_get_time() %}
|
|
141
146
|
|
|
142
147
|
{% set column_added = false %}
|
|
143
148
|
|
|
@@ -162,7 +167,8 @@
|
|
|
162
167
|
)
|
|
163
168
|
{%- endset %}
|
|
164
169
|
|
|
165
|
-
{% set
|
|
170
|
+
{% set scd_args = api.Relation.scd_args(primary_key, updated_at) %}
|
|
171
|
+
{% set scd_id_expr = snapshot_hash_arguments(scd_args) %}
|
|
166
172
|
|
|
167
173
|
{% do return({
|
|
168
174
|
"unique_key": primary_key,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: dbt-adapters
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.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
|
|
6
6
|
Project-URL: Documentation, https://docs.getdbt.com
|
|
@@ -16,14 +16,13 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
16
16
|
Classifier: Operating System :: MacOS :: MacOS X
|
|
17
17
|
Classifier: Operating System :: Microsoft :: Windows
|
|
18
18
|
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.9
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
23
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
-
Requires-Python: >=3.
|
|
23
|
+
Requires-Python: >=3.9.0
|
|
25
24
|
Requires-Dist: agate<2.0,>=1.0
|
|
26
|
-
Requires-Dist: dbt-common<2.0,>=1.
|
|
25
|
+
Requires-Dist: dbt-common<2.0,>=1.11
|
|
27
26
|
Requires-Dist: mashumaro[msgpack]<4.0,>=3.0
|
|
28
27
|
Requires-Dist: protobuf<5.0,>=3.0
|
|
29
28
|
Requires-Dist: pytz>=2015.7
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
dbt/__init__.py,sha256=iY4jdvOxcDhkdr5FiyOTZPHadKtMZDQ-qC6Fw6_EHPM,277
|
|
2
|
-
dbt/adapters/__about__.py,sha256=
|
|
2
|
+
dbt/adapters/__about__.py,sha256=nmG3pZh3PHNxtCaqlmZrGx0G1CNyDdjUYvAO0SpMB8E,18
|
|
3
3
|
dbt/adapters/__init__.py,sha256=3noHsg-64qI0_Pw6OR9F7l1vU2_qrJvinq8POTtuaZM,252
|
|
4
4
|
dbt/adapters/cache.py,sha256=WGy4ewnz-J13LverTACBW2iFhGswrWLgm-wiBrQnMzo,20084
|
|
5
5
|
dbt/adapters/capability.py,sha256=-Mbej2AL_bjQatHpFWUgsQ8z0zwnotyE9Y5DYHnX7NE,2364
|
|
@@ -12,11 +12,11 @@ dbt/adapters/base/README.md,sha256=muHQntC07Lh6L1XfVgwKhV5RltOPBLYPdQqd8_7l34c,5
|
|
|
12
12
|
dbt/adapters/base/__init__.py,sha256=KGGGbj8jGMjAFJdQ5YHcOpApMMVZ_6Xuni1swhpkqRY,423
|
|
13
13
|
dbt/adapters/base/column.py,sha256=Uj20UixoxCn2rlv4QDNONyys6CDkDFyG3anCXKf0T2c,5350
|
|
14
14
|
dbt/adapters/base/connections.py,sha256=-C5dOwGgMKH8n_v6wjwOxV7chBdS0GjOGwNQCUbhhWc,16951
|
|
15
|
-
dbt/adapters/base/impl.py,sha256=
|
|
15
|
+
dbt/adapters/base/impl.py,sha256=7dUeQxHUaC8UpHHayacgUKP2JGGuWgfoh_I00YjN6yc,70604
|
|
16
16
|
dbt/adapters/base/meta.py,sha256=IKqviGf7gK_qGtrn0t8NaSdUaw8g_M8SjICacMvNwGY,5702
|
|
17
17
|
dbt/adapters/base/plugin.py,sha256=rm0GjNHnWM2mn0GJOjciZLwn-02xlzWCoMT9u-epwP0,1076
|
|
18
18
|
dbt/adapters/base/query_headers.py,sha256=UluGd9IYCYkoMiDi5Yx_lnrCOSjWppjwRro4SIGgx8I,3496
|
|
19
|
-
dbt/adapters/base/relation.py,sha256=
|
|
19
|
+
dbt/adapters/base/relation.py,sha256=uBvDb3XwYSu5t5RVj-OwfQgJFcxP9qBPgSqgQ_yzYbI,18708
|
|
20
20
|
dbt/adapters/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
21
|
dbt/adapters/clients/jinja.py,sha256=NsZOiBpOLunS46hRL5OcX1MpY3Ih6_87Vgz4qd_PNbc,768
|
|
22
22
|
dbt/adapters/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -33,7 +33,7 @@ dbt/adapters/events/types.py,sha256=nW7_FgrEmWlM-HWPHrYcJ5K5QLZtfspLizyqlXrJaoE,
|
|
|
33
33
|
dbt/adapters/exceptions/__init__.py,sha256=LxRkxHARMzrPegrjha5tQ8vQi1PnL_ooq1SVqm9aiZs,1268
|
|
34
34
|
dbt/adapters/exceptions/alias.py,sha256=QlCd2jvatfndec1DQLMMBJ-C_7w8yAySuAFHK2ga1g8,798
|
|
35
35
|
dbt/adapters/exceptions/cache.py,sha256=u720DQQKm8pyf_9loD9HGA9WgaeZAlg0sBn0sGc-rhA,2492
|
|
36
|
-
dbt/adapters/exceptions/compilation.py,sha256=
|
|
36
|
+
dbt/adapters/exceptions/compilation.py,sha256=2QsAX-z_1K4q8jGtvbC1JM6dEh7lyOF7rTWkV6RXC8o,8720
|
|
37
37
|
dbt/adapters/exceptions/connection.py,sha256=x82j2Ix242Slm6Ima8Tol3GLOB9yZYH5lq6IV1WKq54,445
|
|
38
38
|
dbt/adapters/exceptions/database.py,sha256=nIXJdQyPQOZaiKvCkQ3MoKlKOiaN58rtDZflw3CSkug,1618
|
|
39
39
|
dbt/adapters/record/__init__.py,sha256=u_0eJzN5RL90oL-RNoP2wWGMCGp0kG0lZ0uVWnnGdxs,123
|
|
@@ -87,17 +87,17 @@ dbt/include/global_project/macros/materializations/models/clone/can_clone_table.
|
|
|
87
87
|
dbt/include/global_project/macros/materializations/models/clone/clone.sql,sha256=X85U0zwq_OINxeZ7JDer9i3BgQZvgGM-tKTvITrQx5s,2716
|
|
88
88
|
dbt/include/global_project/macros/materializations/models/clone/create_or_replace_clone.sql,sha256=qr33DwFOpRG0wGVsGvr63-MexYMNZC9xKdGOPmICp_c,367
|
|
89
89
|
dbt/include/global_project/macros/materializations/models/incremental/column_helpers.sql,sha256=hslQlGKW0oW97srfugsFVRR-L6RrzRcnwr3uLhzI0X4,2577
|
|
90
|
-
dbt/include/global_project/macros/materializations/models/incremental/incremental.sql,sha256=
|
|
90
|
+
dbt/include/global_project/macros/materializations/models/incremental/incremental.sql,sha256=8gyBXan-saJ9GTSa8d05vMa-RSwyZ7pStOeHJpHU4BI,4374
|
|
91
91
|
dbt/include/global_project/macros/materializations/models/incremental/is_incremental.sql,sha256=Sm1TqOeqcCQofj3REFcA97yukPB1J_mClDd55r5GewE,478
|
|
92
92
|
dbt/include/global_project/macros/materializations/models/incremental/merge.sql,sha256=Xg5-Gc9jHego-wpdfg6yEIQv7EClz6-xcJEeFXuZiwQ,5197
|
|
93
93
|
dbt/include/global_project/macros/materializations/models/incremental/on_schema_change.sql,sha256=EOgcrYhwOGVPnyaBu7kIfe8LTOYVOu-AhxMtBs8ETpQ,4927
|
|
94
94
|
dbt/include/global_project/macros/materializations/models/incremental/strategies.sql,sha256=ORGWiYfj-b3_VIps9FDlyx-Q4A2hZzX2aYLocW8b6pU,2613
|
|
95
95
|
dbt/include/global_project/macros/materializations/seeds/helpers.sql,sha256=Y15ej-D3gm1ExIOMNT208q43gRk8d985WQBuGSooNL0,3920
|
|
96
96
|
dbt/include/global_project/macros/materializations/seeds/seed.sql,sha256=YSoGzVO3iIUiOKIUM9G7yApGLFH4O9bv_d4KjHo3p4Q,2155
|
|
97
|
-
dbt/include/global_project/macros/materializations/snapshots/helpers.sql,sha256=
|
|
98
|
-
dbt/include/global_project/macros/materializations/snapshots/snapshot.sql,sha256=
|
|
99
|
-
dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql,sha256
|
|
100
|
-
dbt/include/global_project/macros/materializations/snapshots/strategies.sql,sha256=
|
|
97
|
+
dbt/include/global_project/macros/materializations/snapshots/helpers.sql,sha256=h7VuSOq7gYwh2G2sh16AjP-57SsDG1M_ail22RNHAOk,8550
|
|
98
|
+
dbt/include/global_project/macros/materializations/snapshots/snapshot.sql,sha256=zxFMzo9MHii__ciSOGSoUT3dtBmSqHjtkIc9xah8axw,4011
|
|
99
|
+
dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql,sha256=-uCvd2_E4AfWWEBRyQLiGCpuHgOG-MczlbLIWyGfAzM,1287
|
|
100
|
+
dbt/include/global_project/macros/materializations/snapshots/strategies.sql,sha256=5NB6nHW6qi-IcSf-ALwokTKHfOfV5Hzz4tGotgrV7JA,6746
|
|
101
101
|
dbt/include/global_project/macros/materializations/tests/helpers.sql,sha256=rxUxDZm4EvrDbi0H_ePghE34_QLmxGEY2o_LTMc9CU0,1731
|
|
102
102
|
dbt/include/global_project/macros/materializations/tests/test.sql,sha256=Rz3O_3dWHlIofG3d2CwsP2bXFimRZUIwOevyB0iz1J4,1831
|
|
103
103
|
dbt/include/global_project/macros/materializations/tests/unit.sql,sha256=KonePuFfwcz5uJ-JW0CrEy8_q-Gl45fonngGmFvQcNU,1252
|
|
@@ -157,7 +157,7 @@ dbt/include/global_project/macros/utils/right.sql,sha256=EwNG98CAFIwNDmarwopf7Rk
|
|
|
157
157
|
dbt/include/global_project/macros/utils/safe_cast.sql,sha256=1mswwkDACmIi1I99JKb_-vq3kjMe4HhMRV70mW8Bt4Y,298
|
|
158
158
|
dbt/include/global_project/macros/utils/split_part.sql,sha256=fXEIS0oIiYR7-4lYbb0QbZdG-q2TpV63AFd1ky4I5UM,714
|
|
159
159
|
dbt/include/global_project/tests/generic/builtin.sql,sha256=p94xdyPwb2TlxgLBqCfrcRfJ1QNgsjPvBm8f0Q5eqZM,1022
|
|
160
|
-
dbt_adapters-1.
|
|
161
|
-
dbt_adapters-1.
|
|
162
|
-
dbt_adapters-1.
|
|
163
|
-
dbt_adapters-1.
|
|
160
|
+
dbt_adapters-1.7.2.dist-info/METADATA,sha256=MBPlx_JfK9iYRkF61AxSwob5KA15Y_4irl6FW99QO7Y,2498
|
|
161
|
+
dbt_adapters-1.7.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
162
|
+
dbt_adapters-1.7.2.dist-info/licenses/LICENSE,sha256=9yjigiJhWcCZvQjdagGKDwrRph58QWc5P2bVSQwXo6s,11344
|
|
163
|
+
dbt_adapters-1.7.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|