dbt-adapters 1.12.0__py3-none-any.whl → 1.13.1__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 +40 -37
- dbt/include/global_project/macros/adapters/freshness.sql +16 -0
- dbt/include/global_project/macros/adapters/show.sql +1 -1
- dbt/include/global_project/macros/materializations/snapshots/helpers.sql +6 -3
- dbt/include/global_project/macros/relations/replace.sql +1 -1
- {dbt_adapters-1.12.0.dist-info → dbt_adapters-1.13.1.dist-info}/METADATA +1 -1
- {dbt_adapters-1.12.0.dist-info → dbt_adapters-1.13.1.dist-info}/RECORD +10 -10
- {dbt_adapters-1.12.0.dist-info → dbt_adapters-1.13.1.dist-info}/WHEEL +0 -0
- {dbt_adapters-1.12.0.dist-info → dbt_adapters-1.13.1.dist-info}/licenses/LICENSE +0 -0
dbt/adapters/__about__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
version = "1.
|
|
1
|
+
version = "1.13.1"
|
dbt/adapters/base/impl.py
CHANGED
|
@@ -97,6 +97,7 @@ if TYPE_CHECKING:
|
|
|
97
97
|
GET_CATALOG_MACRO_NAME = "get_catalog"
|
|
98
98
|
GET_CATALOG_RELATIONS_MACRO_NAME = "get_catalog_relations"
|
|
99
99
|
FRESHNESS_MACRO_NAME = "collect_freshness"
|
|
100
|
+
CUSTOM_SQL_FRESHNESS_MACRO_NAME = "collect_freshness_custom_sql"
|
|
100
101
|
GET_RELATION_LAST_MODIFIED_MACRO_NAME = "get_relation_last_modified"
|
|
101
102
|
DEFAULT_BASE_BEHAVIOR_FLAGS = [
|
|
102
103
|
{
|
|
@@ -1327,6 +1328,31 @@ class BaseAdapter(metaclass=AdapterMeta):
|
|
|
1327
1328
|
"""Cancel all open connections."""
|
|
1328
1329
|
return self.connections.cancel_open()
|
|
1329
1330
|
|
|
1331
|
+
def _process_freshness_execution(
|
|
1332
|
+
self,
|
|
1333
|
+
macro_name: str,
|
|
1334
|
+
kwargs: Dict[str, Any],
|
|
1335
|
+
macro_resolver: Optional[MacroResolverProtocol] = None,
|
|
1336
|
+
) -> Tuple[Optional[AdapterResponse], FreshnessResponse]:
|
|
1337
|
+
"""Execute and process a freshness macro to generate a FreshnessResponse"""
|
|
1338
|
+
import agate
|
|
1339
|
+
|
|
1340
|
+
result = self.execute_macro(macro_name, kwargs=kwargs, macro_resolver=macro_resolver)
|
|
1341
|
+
|
|
1342
|
+
if isinstance(result, agate.Table):
|
|
1343
|
+
warn_or_error(CollectFreshnessReturnSignature())
|
|
1344
|
+
table = result
|
|
1345
|
+
adapter_response = None
|
|
1346
|
+
else:
|
|
1347
|
+
adapter_response, table = result.response, result.table
|
|
1348
|
+
|
|
1349
|
+
# Process the results table
|
|
1350
|
+
if len(table) != 1 or len(table[0]) != 2:
|
|
1351
|
+
raise MacroResultError(macro_name, table)
|
|
1352
|
+
|
|
1353
|
+
freshness_response = self._create_freshness_response(table[0][0], table[0][1])
|
|
1354
|
+
return adapter_response, freshness_response
|
|
1355
|
+
|
|
1330
1356
|
def calculate_freshness(
|
|
1331
1357
|
self,
|
|
1332
1358
|
source: BaseRelation,
|
|
@@ -1335,49 +1361,26 @@ class BaseAdapter(metaclass=AdapterMeta):
|
|
|
1335
1361
|
macro_resolver: Optional[MacroResolverProtocol] = None,
|
|
1336
1362
|
) -> Tuple[Optional[AdapterResponse], FreshnessResponse]:
|
|
1337
1363
|
"""Calculate the freshness of sources in dbt, and return it"""
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
kwargs: Dict[str, Any] = {
|
|
1364
|
+
kwargs = {
|
|
1341
1365
|
"source": source,
|
|
1342
1366
|
"loaded_at_field": loaded_at_field,
|
|
1343
1367
|
"filter": filter,
|
|
1344
1368
|
}
|
|
1369
|
+
return self._process_freshness_execution(FRESHNESS_MACRO_NAME, kwargs, macro_resolver)
|
|
1345
1370
|
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
)
|
|
1356
|
-
if isinstance(result, agate.Table):
|
|
1357
|
-
warn_or_error(CollectFreshnessReturnSignature())
|
|
1358
|
-
adapter_response = None
|
|
1359
|
-
table = result
|
|
1360
|
-
else:
|
|
1361
|
-
adapter_response, table = result.response, result.table # type: ignore[attr-defined]
|
|
1362
|
-
# now we have a 1-row table of the maximum `loaded_at_field` value and
|
|
1363
|
-
# the current time according to the db.
|
|
1364
|
-
if len(table) != 1 or len(table[0]) != 2:
|
|
1365
|
-
raise MacroResultError(FRESHNESS_MACRO_NAME, table)
|
|
1366
|
-
if table[0][0] is None:
|
|
1367
|
-
# no records in the table, so really the max_loaded_at was
|
|
1368
|
-
# infinitely long ago. Just call it 0:00 January 1 year UTC
|
|
1369
|
-
max_loaded_at = datetime(1, 1, 1, 0, 0, 0, tzinfo=pytz.UTC)
|
|
1370
|
-
else:
|
|
1371
|
-
max_loaded_at = _utc(table[0][0], source, loaded_at_field)
|
|
1372
|
-
|
|
1373
|
-
snapshotted_at = _utc(table[0][1], source, loaded_at_field)
|
|
1374
|
-
age = (snapshotted_at - max_loaded_at).total_seconds()
|
|
1375
|
-
freshness: FreshnessResponse = {
|
|
1376
|
-
"max_loaded_at": max_loaded_at,
|
|
1377
|
-
"snapshotted_at": snapshotted_at,
|
|
1378
|
-
"age": age,
|
|
1371
|
+
def calculate_freshness_from_custom_sql(
|
|
1372
|
+
self,
|
|
1373
|
+
source: BaseRelation,
|
|
1374
|
+
sql: str,
|
|
1375
|
+
macro_resolver: Optional[MacroResolverProtocol] = None,
|
|
1376
|
+
) -> Tuple[Optional[AdapterResponse], FreshnessResponse]:
|
|
1377
|
+
kwargs = {
|
|
1378
|
+
"source": source,
|
|
1379
|
+
"loaded_at_query": sql,
|
|
1379
1380
|
}
|
|
1380
|
-
return
|
|
1381
|
+
return self._process_freshness_execution(
|
|
1382
|
+
CUSTOM_SQL_FRESHNESS_MACRO_NAME, kwargs, macro_resolver
|
|
1383
|
+
)
|
|
1381
1384
|
|
|
1382
1385
|
def calculate_freshness_from_metadata_batch(
|
|
1383
1386
|
self,
|
|
@@ -14,3 +14,19 @@
|
|
|
14
14
|
{% endcall %}
|
|
15
15
|
{{ return(load_result('collect_freshness')) }}
|
|
16
16
|
{% endmacro %}
|
|
17
|
+
|
|
18
|
+
{% macro collect_freshness_custom_sql(source, loaded_at_query) %}
|
|
19
|
+
{{ return(adapter.dispatch('collect_freshness_custom_sql', 'dbt')(source, loaded_at_query))}}
|
|
20
|
+
{% endmacro %}
|
|
21
|
+
|
|
22
|
+
{% macro default__collect_freshness_custom_sql(source, loaded_at_query) %}
|
|
23
|
+
{% call statement('collect_freshness_custom_sql', fetch_result=True, auto_begin=False) -%}
|
|
24
|
+
with source_query as (
|
|
25
|
+
{{ loaded_at_query }}
|
|
26
|
+
)
|
|
27
|
+
select
|
|
28
|
+
(select * from source_query) as max_loaded_at,
|
|
29
|
+
{{ current_timestamp() }} as snapshotted_at
|
|
30
|
+
{% endcall %}
|
|
31
|
+
{{ return(load_result('collect_freshness_custom_sql')) }}
|
|
32
|
+
{% endmacro %}
|
|
@@ -40,7 +40,9 @@
|
|
|
40
40
|
|
|
41
41
|
{% macro default__snapshot_staging_table(strategy, source_sql, target_relation) -%}
|
|
42
42
|
{% set columns = config.get('snapshot_table_column_names') or get_snapshot_table_column_names() %}
|
|
43
|
-
|
|
43
|
+
{% if strategy.hard_deletes == 'new_record' %}
|
|
44
|
+
{% set new_scd_id = snapshot_hash_arguments([columns.dbt_scd_id, snapshot_get_time()]) %}
|
|
45
|
+
{% endif %}
|
|
44
46
|
with snapshot_query as (
|
|
45
47
|
|
|
46
48
|
{{ source_sql }}
|
|
@@ -169,12 +171,13 @@
|
|
|
169
171
|
{{ snapshot_get_time() }} as {{ columns.dbt_valid_from }},
|
|
170
172
|
{{ snapshot_get_time() }} as {{ columns.dbt_updated_at }},
|
|
171
173
|
snapshotted_data.{{ columns.dbt_valid_to }} as {{ columns.dbt_valid_to }},
|
|
172
|
-
|
|
174
|
+
{{ new_scd_id }} as {{ columns.dbt_scd_id }},
|
|
173
175
|
'True' as {{ columns.dbt_is_deleted }}
|
|
174
176
|
from snapshotted_data
|
|
175
177
|
left join deletes_source_data as source_data
|
|
176
178
|
on {{ unique_key_join_on(strategy.unique_key, "snapshotted_data", "source_data") }}
|
|
177
|
-
|
|
179
|
+
where {{ unique_key_is_null(strategy.unique_key, "source_data") }}
|
|
180
|
+
|
|
178
181
|
)
|
|
179
182
|
{%- endif %}
|
|
180
183
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
{# /* use a create or replace statement if possible */ #}
|
|
10
10
|
|
|
11
|
-
{% set is_replaceable = existing_relation.type ==
|
|
11
|
+
{% set is_replaceable = existing_relation.type == target_relation.type and existing_relation.can_be_replaced %}
|
|
12
12
|
|
|
13
13
|
{% if is_replaceable and existing_relation.is_view %}
|
|
14
14
|
{{ get_replace_view_sql(target_relation, sql) }}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dbt-adapters
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.13.1
|
|
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
|
|
@@ -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=ofhIPYFjTzjdL3uc7wpw3-87PyOAQCzpoAiweYqYRzM,19
|
|
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=M3FkC9veKnNB7a7uQyl7EHX_AGNXPChbHAkcY4cgXCY,2534
|
|
@@ -12,7 +12,7 @@ dbt/adapters/base/README.md,sha256=muHQntC07Lh6L1XfVgwKhV5RltOPBLYPdQqd8_7l34c,5
|
|
|
12
12
|
dbt/adapters/base/__init__.py,sha256=Nc8lQVkOzAqdcxk4cw4E_raxN9CAWMwhQx4STdiicxg,456
|
|
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=c-tUGbkZjXfKtc7gBK2qlJITdYINJoCQu75ckBFNS8I,74803
|
|
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
|
|
@@ -60,13 +60,13 @@ dbt/include/global_project/dbt_project.yml,sha256=RTtOhnBpEL0gbd1GlpxuVr6eZJBPvg
|
|
|
60
60
|
dbt/include/global_project/docs/overview.md,sha256=VuObM4pcS-TvwYeAjjUbe0TBhEnxf6g30EPWrGjya_w,1824
|
|
61
61
|
dbt/include/global_project/macros/adapters/apply_grants.sql,sha256=3NUJLWmNE0ZAWxc1LuIpo6-dTfLEBjX1Os5BdDb_IOQ,6861
|
|
62
62
|
dbt/include/global_project/macros/adapters/columns.sql,sha256=21cb0Q8A3oDbajV7oL06arDcmg-YuvWRmQ-07KeI-dk,5483
|
|
63
|
-
dbt/include/global_project/macros/adapters/freshness.sql,sha256=
|
|
63
|
+
dbt/include/global_project/macros/adapters/freshness.sql,sha256=bl2Kn7s2pDMzrJWeLXYyUVYXDmloLxntjOgyWSDcgCs,1200
|
|
64
64
|
dbt/include/global_project/macros/adapters/indexes.sql,sha256=DasPn32Cm0OZyjBPBWzL4BpK9PZ3xF_Pu8Nh4NgASaw,1366
|
|
65
65
|
dbt/include/global_project/macros/adapters/metadata.sql,sha256=meNIc3z4lXdh1lDb-K1utKb8VzAVuN23E6XWgMZGDhQ,3512
|
|
66
66
|
dbt/include/global_project/macros/adapters/persist_docs.sql,sha256=TUazJHSaMIDlELqALLRMC2kYj5DGZ9U-6K8RbgwRXw4,1369
|
|
67
67
|
dbt/include/global_project/macros/adapters/relation.sql,sha256=yT4YVCipxeQAjkj98rscCNt-slC8oIJXriHlkvzbkQ0,3016
|
|
68
68
|
dbt/include/global_project/macros/adapters/schema.sql,sha256=XElo0cfvdEipI5hpulLXLBEXP_YnilG-1kRwDMqDD5I,594
|
|
69
|
-
dbt/include/global_project/macros/adapters/show.sql,sha256=
|
|
69
|
+
dbt/include/global_project/macros/adapters/show.sql,sha256=IUDcMxctFksaaIfnCtyJqu_MarwEldhegtzHcxDwUQg,775
|
|
70
70
|
dbt/include/global_project/macros/adapters/timestamps.sql,sha256=FvPwWkmM00r9rs2DjR5wrI-U9ah3-8VMIwk5wRRzuPw,1910
|
|
71
71
|
dbt/include/global_project/macros/adapters/validate_sql.sql,sha256=IC-HEVv8Cl8nd7dic_U4hyqlrkdO6plPbH914OdM_WE,285
|
|
72
72
|
dbt/include/global_project/macros/etc/datetime.sql,sha256=HwNxXw0xHHLVKFBlbbc4wqTdYe6_smku1EwWGM7G-6g,2185
|
|
@@ -94,7 +94,7 @@ dbt/include/global_project/macros/materializations/models/incremental/on_schema_
|
|
|
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
|
|
97
|
+
dbt/include/global_project/macros/materializations/snapshots/helpers.sql,sha256=-3fPrZylQCT3nYfRq1bb9C__9wnA91i3lXI__bWmpkk,10843
|
|
98
98
|
dbt/include/global_project/macros/materializations/snapshots/snapshot.sql,sha256=clIZtCE7vvOXxzz1t2KlmPZM7AuSGsK7MInspo0N5Qg,4043
|
|
99
99
|
dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql,sha256=-uCvd2_E4AfWWEBRyQLiGCpuHgOG-MczlbLIWyGfAzM,1287
|
|
100
100
|
dbt/include/global_project/macros/materializations/snapshots/strategies.sql,sha256=AfIsRiw0YnQym5wUiWR2JpiEEky4_WBTpTtE0HJvpZw,6928
|
|
@@ -110,7 +110,7 @@ dbt/include/global_project/macros/relations/drop.sql,sha256=UL40SxBjHLPpIHywKYHZ
|
|
|
110
110
|
dbt/include/global_project/macros/relations/drop_backup.sql,sha256=PTbx_bN27aqCv9HD9I7Td5rJaRrH23TXDs9aC5ei8Q8,415
|
|
111
111
|
dbt/include/global_project/macros/relations/rename.sql,sha256=0YLUnZtov5FOtr-j7CjI4LNtXWojWGER2q1lVbJMH5c,1183
|
|
112
112
|
dbt/include/global_project/macros/relations/rename_intermediate.sql,sha256=rhcK6jeo5gfQ-1rqFd2lyTT4HtAzu8Ndzbz2FzHMBhs,479
|
|
113
|
-
dbt/include/global_project/macros/relations/replace.sql,sha256=
|
|
113
|
+
dbt/include/global_project/macros/relations/replace.sql,sha256=rzkMGfT0LO1z-0G7nXq_R8bkVF10iEd5Ct4Kuf7GI4o,2295
|
|
114
114
|
dbt/include/global_project/macros/relations/schema.sql,sha256=kOQeEZQwycGGtAoq_KM6EyvEhquFk8jnx81nT31s58M,318
|
|
115
115
|
dbt/include/global_project/macros/relations/column/columns_spec_ddl.sql,sha256=ukW4iLuAXYfsrnlfeY26cFMMFxATcNV8hlp9valOx8U,3676
|
|
116
116
|
dbt/include/global_project/macros/relations/materialized_view/alter.sql,sha256=pZcZa1xfcZZpVVSvvJ3YR0zn6noIKBfkTSbrqKohAcU,1806
|
|
@@ -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.13.1.dist-info/METADATA,sha256=uRyktzA_PII5ygtT1nGEYLT0PyIA0cV1lFkgJa29WAI,2576
|
|
161
|
+
dbt_adapters-1.13.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
162
|
+
dbt_adapters-1.13.1.dist-info/licenses/LICENSE,sha256=9yjigiJhWcCZvQjdagGKDwrRph58QWc5P2bVSQwXo6s,11344
|
|
163
|
+
dbt_adapters-1.13.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|