dbt-adapters 1.16.6__py3-none-any.whl → 1.17.0__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.6"
1
+ version = "1.17.0"
@@ -376,12 +376,17 @@ class BaseRelation(FakeAPIObject, Hashable):
376
376
  return hash(self.render())
377
377
 
378
378
  def __str__(self) -> str:
379
- rendered = self.render() if self.limit is None else self.render_limited()
379
+ # TODO: This function seems to have more if's than it needs to. We should see if we can simplify it.
380
+ if self.is_function:
381
+ # If it's a function we skip all special rendering logic and just return the raw render
382
+ rendered = self.render()
383
+ else:
384
+ rendered = self.render() if self.limit is None else self.render_limited()
380
385
 
381
- # Limited subquery is wrapped by the event time filter subquery, and not the other way around.
382
- # This is because in the context of resolving limited refs, we care more about performance than reliably producing a sample of a certain size.
383
- if self.event_time_filter:
384
- rendered = self.render_event_time_filtered(rendered)
386
+ # Limited subquery is wrapped by the event time filter subquery, and not the other way around.
387
+ # This is because in the context of resolving limited refs, we care more about performance than reliably producing a sample of a certain size.
388
+ if self.event_time_filter:
389
+ rendered = self.render_event_time_filtered(rendered)
385
390
 
386
391
  return rendered
387
392
 
@@ -426,6 +431,10 @@ class BaseRelation(FakeAPIObject, Hashable):
426
431
  def is_pointer(self) -> bool:
427
432
  return self.type == RelationType.PointerTable
428
433
 
434
+ @property
435
+ def is_function(self) -> bool:
436
+ return self.type == RelationType.Function
437
+
429
438
  @classproperty
430
439
  def Table(cls) -> str:
431
440
  return str(RelationType.Table)
@@ -450,6 +459,10 @@ class BaseRelation(FakeAPIObject, Hashable):
450
459
  def PointerTable(cls) -> str:
451
460
  return str(RelationType.PointerTable)
452
461
 
462
+ @classproperty
463
+ def Function(cls) -> str:
464
+ return str(RelationType.Function)
465
+
453
466
  @classproperty
454
467
  def get_relation_type(cls) -> Type[RelationType]:
455
468
  return RelationType
@@ -22,6 +22,7 @@ class RelationType(StrEnum):
22
22
  # this is a "catch all" that is better than `None` == external to anything dbt is aware of
23
23
  External = "external"
24
24
  PointerTable = "pointer_table"
25
+ Function = "function"
25
26
 
26
27
 
27
28
  class MaterializationContract(Protocol):
@@ -0,0 +1,16 @@
1
+ {% materialization function, default %}
2
+ {% set existing_relation = load_cached_relation(this) %}
3
+ {% set target_relation = this.incorporate(type=this.Function) %}
4
+
5
+ {{ run_hooks(pre_hooks) }}
6
+
7
+ {% set function_type_macro = get_function_macro('scalar', 'sql') %}
8
+ {% set build_sql = function_type_macro(target_relation) %}
9
+
10
+ {{ function_execute_build_sql(build_sql, existing_relation, target_relation) }}
11
+
12
+ {{ run_hooks(post_hooks) }}
13
+
14
+ {{ return({'relations': [target_relation]}) }}
15
+
16
+ {% endmaterialization %}
@@ -0,0 +1,34 @@
1
+ {% macro function_execute_build_sql(build_sql, existing_relation, target_relation) %}
2
+ {{ return(adapter.dispatch('function_execute_build_sql', 'dbt')(build_sql, existing_relation, target_relation)) }}
3
+ {% endmacro %}
4
+
5
+ {% macro default__function_execute_build_sql(build_sql, existing_relation, target_relation) %}
6
+
7
+ {% set grant_config = config.get('grants') %}
8
+
9
+ {% call statement(name="main") %}
10
+ {{ build_sql }}
11
+ {% endcall %}
12
+
13
+ {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}
14
+ {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}
15
+
16
+ {% do persist_docs(target_relation, model) %}
17
+
18
+ {{ adapter.commit() }}
19
+
20
+ {% endmacro %}
21
+
22
+
23
+ {% macro get_function_macro(function_type, function_language) %}
24
+ {{ return(adapter.dispatch('get_function_macro', 'dbt')(function_type, function_language)) }}
25
+ {% endmacro %}
26
+
27
+ {% macro default__get_function_macro(function_type, function_language) %}
28
+ {% set macro_name = function_type ~ "_function_" ~ function_language %}
29
+ {% if not macro_name in context %}
30
+ {{ exceptions.raise_not_implemented(function_language ~ ' ' ~ function_type ~ ' function not implemented for adapter ' ~adapter.type()) }}
31
+ {% endif %}
32
+ {% set macro = context[macro_name] %}
33
+ {{ return(macro) }}
34
+ {% endmacro %}
@@ -0,0 +1,38 @@
1
+ {% macro scalar_function_sql(target_relation) %}
2
+ {{ return(adapter.dispatch('scalar_function_sql', 'dbt')(target_relation)) }}
3
+ {% endmacro %}
4
+
5
+ {% macro default__scalar_function_sql(target_relation) %}
6
+ {{ scalar_function_create_replace_signature_sql(target_relation) }}
7
+ {{ scalar_function_body_sql() }};
8
+ {% endmacro %}
9
+
10
+ {% macro scalar_function_create_replace_signature_sql(target_relation) %}
11
+ {{ return(adapter.dispatch('scalar_function_create_replace_signature_sql', 'dbt')(target_relation)) }}
12
+ {% endmacro %}
13
+
14
+ {% macro default__scalar_function_create_replace_signature_sql(target_relation) %}
15
+ CREATE OR REPLACE FUNCTION {{ target_relation.render() }} ({{ formatted_scalar_function_args_sql()}}) RETURNS {{ model.return_type.type }} AS
16
+ {% endmacro %}
17
+
18
+ {% macro formatted_scalar_function_args_sql() %}
19
+ {{ return(adapter.dispatch('formatted_scalar_function_args_sql', 'dbt')()) }}
20
+ {% endmacro %}
21
+
22
+ {% macro default__formatted_scalar_function_args_sql() %}
23
+ {% set args = [] %}
24
+ {% for arg in model.arguments -%}
25
+ {%- do args.append(arg.name ~ ' ' ~ arg.type) -%}
26
+ {%- endfor %}
27
+ {{ args | join(', ') }}
28
+ {% endmacro %}
29
+
30
+ {% macro scalar_function_body_sql() %}
31
+ {{ return(adapter.dispatch('scalar_function_body_sql', 'dbt')()) }}
32
+ {% endmacro %}
33
+
34
+ {% macro default__scalar_function_body_sql() %}
35
+ $$
36
+ {{ model.compiled_code }}
37
+ $$ LANGUAGE SQL;
38
+ {% endmacro %}
@@ -158,7 +158,12 @@
158
158
  and not (
159
159
  --avoid updating the record's valid_to if the latest entry is marked as deleted
160
160
  snapshotted_data.{{ columns.dbt_is_deleted }} = 'True'
161
- and snapshotted_data.{{ columns.dbt_valid_to }} is null
161
+ and
162
+ {% if config.get('dbt_valid_to_current') -%}
163
+ snapshotted_data.{{ columns.dbt_valid_to }} = {{ config.get('dbt_valid_to_current') }}
164
+ {%- else -%}
165
+ snapshotted_data.{{ columns.dbt_valid_to }} is null
166
+ {%- endif %}
162
167
  )
163
168
  {%- endif %}
164
169
  )
@@ -172,10 +177,10 @@
172
177
 
173
178
  select
174
179
  'insert' as dbt_change_type,
175
- {#
180
+ {#/*
176
181
  If a column has been added to the source it won't yet exist in the
177
182
  snapshotted table so we insert a null value as a placeholder for the column.
178
- #}
183
+ */#}
179
184
  {%- for col in source_sql_cols -%}
180
185
  {%- if col.name in snapshotted_cols -%}
181
186
  snapshotted_data.{{ adapter.quote(col.column) }},
@@ -202,7 +207,12 @@
202
207
  and not (
203
208
  --avoid inserting a new record if the latest one is marked as deleted
204
209
  snapshotted_data.{{ columns.dbt_is_deleted }} = 'True'
205
- and snapshotted_data.{{ columns.dbt_valid_to }} is null
210
+ and
211
+ {% if config.get('dbt_valid_to_current') -%}
212
+ snapshotted_data.{{ columns.dbt_valid_to }} = {{ config.get('dbt_valid_to_current') }}
213
+ {%- else -%}
214
+ snapshotted_data.{{ columns.dbt_valid_to }} is null
215
+ {%- endif %}
206
216
  )
207
217
 
208
218
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dbt-adapters
3
- Version: 1.16.6
3
+ Version: 1.17.0
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=yVGsgH-1PnNg3ANhU0Ki30jCFRQx1ac_0O7ZJ8deZa8,19
1
+ dbt/adapters/__about__.py,sha256=uYViEABuLbLykJW0jxwSXYZEExCXp3lcdeO8uJWFORw,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
@@ -15,7 +15,7 @@ dbt/adapters/base/impl.py,sha256=uACwbMYJL9KykHdckf-9Egz4MBGecwOsSrYtU72OEx8,791
15
15
  dbt/adapters/base/meta.py,sha256=c5j0qeGec1cAi-IlVV_JkhMk01p5XqbtGj02uxGP1S4,5686
16
16
  dbt/adapters/base/plugin.py,sha256=rm0GjNHnWM2mn0GJOjciZLwn-02xlzWCoMT9u-epwP0,1076
17
17
  dbt/adapters/base/query_headers.py,sha256=rHgux9b_vPp_xRsg8QU3NE202Hho4i4zO9u9Gx_BCF4,3651
18
- dbt/adapters/base/relation.py,sha256=eePneHZQ-bb0ZFaEpC_1xzsxJF38e6k7b3FUxD8PK0I,19383
18
+ dbt/adapters/base/relation.py,sha256=0zRBTipIC--bWNYkkrmc_BlzMRfKZefjiL7w4LKe8kc,19884
19
19
  dbt/adapters/catalogs/__init__.py,sha256=jiZb5IchAHnHSHz5J44l3Wzc0-oHeYXv4_7SBKOL7Pw,498
20
20
  dbt/adapters/catalogs/_client.py,sha256=bIXZxEL1-4kSXHFPnMw3egIOx1fKZmjxKiO1Wv-KuHg,2258
21
21
  dbt/adapters/catalogs/_constants.py,sha256=8O5wLK4oVqirpC9ap7PIXodq8XtkQhHJ5W0OU1xtwjk,55
@@ -26,7 +26,7 @@ dbt/adapters/clients/jinja.py,sha256=NsZOiBpOLunS46hRL5OcX1MpY3Ih6_87Vgz4qd_PNbc
26
26
  dbt/adapters/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  dbt/adapters/contracts/connection.py,sha256=azipef6NBjkh88OcuF90cNUdcYBPXFMl9K99OAwdl_0,6926
28
28
  dbt/adapters/contracts/macros.py,sha256=NYVDi5ww7v4ksKBwF836TXE-2xU4IBaUINqvxMY-ieU,366
29
- dbt/adapters/contracts/relation.py,sha256=DIWjEeEY1QQWBAUjVNLP5WDu2HcMdBPLDwJnh8Xb4wk,4793
29
+ dbt/adapters/contracts/relation.py,sha256=JEt9uTHUelb1aZ0PeUbIASoLL2GrG1Q1Ibr_7oGhigM,4819
30
30
  dbt/adapters/events/README.md,sha256=3rMVP1XO1Lw7Dv6g7-SkDsAcN4VVjIF0fHKopEcCzXk,2689
31
31
  dbt/adapters/events/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  dbt/adapters/events/adapter_types_pb2.py,sha256=Mov1yYR_v9JG6n7MHvzEbFtLN4gMQ1Uv5die8u2eJag,126
@@ -85,6 +85,9 @@ dbt/include/global_project/macros/get_custom_name/get_custom_database.sql,sha256
85
85
  dbt/include/global_project/macros/get_custom_name/get_custom_schema.sql,sha256=2-ZYuDRBo2RSCKZTX7rzm2Y77DVCaHGTnHG9IKNMpvk,1731
86
86
  dbt/include/global_project/macros/materializations/configs.sql,sha256=aciTDXFQoiAU4y8nsreTQnSca18P2tjURx-LQIrzyuc,627
87
87
  dbt/include/global_project/macros/materializations/hooks.sql,sha256=IIOLRanrLtpYcWxWPaPJ7JMoyJdQJicEDni4yoE9mJI,994
88
+ dbt/include/global_project/macros/materializations/functions/function.sql,sha256=V0HHavcQgkTYfCKrOOeJzvXnQSoo73t5Q6OXIdgQglc,534
89
+ dbt/include/global_project/macros/materializations/functions/helpers.sql,sha256=WxVC18nJlkhVzsiWa_5EmVnkBgEj7V1qR8Key08xYTk,1331
90
+ dbt/include/global_project/macros/materializations/functions/scalar.sql,sha256=vAMoO2S7paPLKuOomBSvnfVrHG4kpXthjUaxomOX1u4,1411
88
91
  dbt/include/global_project/macros/materializations/models/materialized_view.sql,sha256=-u0cGQrHEMBt8coXfKKPpUQJS97TX3QRafV873fqeCA,5029
89
92
  dbt/include/global_project/macros/materializations/models/table.sql,sha256=F9ogmZofhPdzKwhhFJ_GfI5QRXQxLjTl6xTiCgulQ9g,2682
90
93
  dbt/include/global_project/macros/materializations/models/view.sql,sha256=LPqM3aTsWiAalFz322aTpqKqCdl4hxN8ubcwXZIIDDw,3249
@@ -99,7 +102,7 @@ dbt/include/global_project/macros/materializations/models/incremental/on_schema_
99
102
  dbt/include/global_project/macros/materializations/models/incremental/strategies.sql,sha256=ORGWiYfj-b3_VIps9FDlyx-Q4A2hZzX2aYLocW8b6pU,2613
100
103
  dbt/include/global_project/macros/materializations/seeds/helpers.sql,sha256=Y15ej-D3gm1ExIOMNT208q43gRk8d985WQBuGSooNL0,3920
101
104
  dbt/include/global_project/macros/materializations/seeds/seed.sql,sha256=YSoGzVO3iIUiOKIUM9G7yApGLFH4O9bv_d4KjHo3p4Q,2155
102
- dbt/include/global_project/macros/materializations/snapshots/helpers.sql,sha256=EdKKm0_uEot5msQbs77iFdTJh-HmuV8hgTLVDT3MNo0,12468
105
+ dbt/include/global_project/macros/materializations/snapshots/helpers.sql,sha256=YWMFCt0VsBHIbzGO3hSY1Zwpxd-dsfaeCzj3RzgqXos,12944
103
106
  dbt/include/global_project/macros/materializations/snapshots/snapshot.sql,sha256=clIZtCE7vvOXxzz1t2KlmPZM7AuSGsK7MInspo0N5Qg,4043
104
107
  dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql,sha256=WaGQCuv4o_qxBw7b2KQvUnSg0UkPklwAQHK1-QngN_M,1369
105
108
  dbt/include/global_project/macros/materializations/snapshots/strategies.sql,sha256=AfIsRiw0YnQym5wUiWR2JpiEEky4_WBTpTtE0HJvpZw,6928
@@ -163,7 +166,7 @@ dbt/include/global_project/macros/utils/right.sql,sha256=EwNG98CAFIwNDmarwopf7Rk
163
166
  dbt/include/global_project/macros/utils/safe_cast.sql,sha256=1mswwkDACmIi1I99JKb_-vq3kjMe4HhMRV70mW8Bt4Y,298
164
167
  dbt/include/global_project/macros/utils/split_part.sql,sha256=fXEIS0oIiYR7-4lYbb0QbZdG-q2TpV63AFd1ky4I5UM,714
165
168
  dbt/include/global_project/tests/generic/builtin.sql,sha256=p94xdyPwb2TlxgLBqCfrcRfJ1QNgsjPvBm8f0Q5eqZM,1022
166
- dbt_adapters-1.16.6.dist-info/METADATA,sha256=vmRysouwZKtOTcNN_y7mnp8m1zKkYdPtrk-9PpKvwW0,4534
167
- dbt_adapters-1.16.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
168
- dbt_adapters-1.16.6.dist-info/licenses/LICENSE,sha256=9yjigiJhWcCZvQjdagGKDwrRph58QWc5P2bVSQwXo6s,11344
169
- dbt_adapters-1.16.6.dist-info/RECORD,,
169
+ dbt_adapters-1.17.0.dist-info/METADATA,sha256=u7phnPdIZf8RBuPdOrTTFFeH8o2W0Hv4fM68f5TP8Xo,4534
170
+ dbt_adapters-1.17.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
171
+ dbt_adapters-1.17.0.dist-info/licenses/LICENSE,sha256=9yjigiJhWcCZvQjdagGKDwrRph58QWc5P2bVSQwXo6s,11344
172
+ dbt_adapters-1.17.0.dist-info/RECORD,,