dbt-adapters 1.3.2__py3-none-any.whl → 1.4.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.

Files changed (38) hide show
  1. dbt/adapters/__about__.py +1 -1
  2. dbt/adapters/base/column.py +0 -3
  3. dbt/adapters/base/impl.py +24 -10
  4. dbt/adapters/record/__init__.py +2 -0
  5. dbt/adapters/record/cursor/cursor.py +54 -0
  6. dbt/adapters/record/cursor/description.py +37 -0
  7. dbt/adapters/record/cursor/execute.py +20 -0
  8. dbt/adapters/record/cursor/fetchall.py +66 -0
  9. dbt/adapters/record/cursor/fetchmany.py +23 -0
  10. dbt/adapters/record/cursor/fetchone.py +23 -0
  11. dbt/adapters/record/cursor/rowcount.py +23 -0
  12. dbt/adapters/record/handle.py +24 -0
  13. dbt/adapters/sql/connections.py +0 -3
  14. dbt/include/global_project/macros/adapters/apply_grants.sql +4 -4
  15. dbt/include/global_project/macros/adapters/columns.sql +5 -5
  16. dbt/include/global_project/macros/adapters/relation.sql +1 -1
  17. dbt/include/global_project/macros/adapters/show.sql +19 -15
  18. dbt/include/global_project/macros/materializations/models/clone/clone.sql +2 -2
  19. dbt/include/global_project/macros/materializations/models/clone/create_or_replace_clone.sql +1 -1
  20. dbt/include/global_project/macros/materializations/models/incremental/incremental.sql +6 -3
  21. dbt/include/global_project/macros/materializations/models/materialized_view.sql +2 -2
  22. dbt/include/global_project/macros/materializations/seeds/helpers.sql +1 -1
  23. dbt/include/global_project/macros/materializations/seeds/seed.sql +1 -1
  24. dbt/include/global_project/macros/materializations/snapshots/helpers.sql +1 -1
  25. dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql +1 -1
  26. dbt/include/global_project/macros/relations/drop.sql +1 -1
  27. dbt/include/global_project/macros/relations/materialized_view/drop.sql +1 -1
  28. dbt/include/global_project/macros/relations/rename.sql +1 -1
  29. dbt/include/global_project/macros/relations/table/drop.sql +1 -1
  30. dbt/include/global_project/macros/relations/view/create.sql +1 -1
  31. dbt/include/global_project/macros/relations/view/drop.sql +1 -1
  32. dbt/include/global_project/macros/relations/view/replace.sql +1 -1
  33. dbt/include/global_project/macros/unit_test_sql/get_fixture_sql.sql +9 -0
  34. {dbt_adapters-1.3.2.dist-info → dbt_adapters-1.4.0.dist-info}/METADATA +3 -3
  35. {dbt_adapters-1.3.2.dist-info → dbt_adapters-1.4.0.dist-info}/RECORD +37 -29
  36. dbt/adapters/record.py +0 -67
  37. {dbt_adapters-1.3.2.dist-info → dbt_adapters-1.4.0.dist-info}/WHEEL +0 -0
  38. {dbt_adapters-1.3.2.dist-info → dbt_adapters-1.4.0.dist-info}/licenses/LICENSE +0 -0
dbt/adapters/__about__.py CHANGED
@@ -1 +1 @@
1
- version = "1.3.2"
1
+ version = "1.4.0"
@@ -123,9 +123,6 @@ class Column:
123
123
  else:
124
124
  return "{}({},{})".format(dtype, precision, scale)
125
125
 
126
- def __repr__(self) -> str:
127
- return "<Column {} ({})>".format(self.name, self.data_type)
128
-
129
126
  @classmethod
130
127
  def from_description(cls, name: str, raw_data_type: str) -> "Column":
131
128
  match = re.match(r"([^(]+)(\([^)]+\))?", raw_data_type)
dbt/adapters/base/impl.py CHANGED
@@ -1602,8 +1602,13 @@ class BaseAdapter(metaclass=AdapterMeta):
1602
1602
  rendered_column_constraint = f"unique {constraint_expression}"
1603
1603
  elif constraint.type == ConstraintType.primary_key:
1604
1604
  rendered_column_constraint = f"primary key {constraint_expression}"
1605
- elif constraint.type == ConstraintType.foreign_key and constraint_expression:
1606
- rendered_column_constraint = f"references {constraint_expression}"
1605
+ elif constraint.type == ConstraintType.foreign_key:
1606
+ if constraint.to and constraint.to_columns:
1607
+ rendered_column_constraint = (
1608
+ f"references {constraint.to} ({', '.join(constraint.to_columns)})"
1609
+ )
1610
+ elif constraint_expression:
1611
+ rendered_column_constraint = f"references {constraint_expression}"
1607
1612
  elif constraint.type == ConstraintType.custom and constraint_expression:
1608
1613
  rendered_column_constraint = constraint_expression
1609
1614
 
@@ -1682,20 +1687,29 @@ class BaseAdapter(metaclass=AdapterMeta):
1682
1687
  rendering."""
1683
1688
  constraint_prefix = f"constraint {constraint.name} " if constraint.name else ""
1684
1689
  column_list = ", ".join(constraint.columns)
1690
+ rendered_model_constraint = None
1691
+
1685
1692
  if constraint.type == ConstraintType.check and constraint.expression:
1686
- return f"{constraint_prefix}check ({constraint.expression})"
1693
+ rendered_model_constraint = f"{constraint_prefix}check ({constraint.expression})"
1687
1694
  elif constraint.type == ConstraintType.unique:
1688
1695
  constraint_expression = f" {constraint.expression}" if constraint.expression else ""
1689
- return f"{constraint_prefix}unique{constraint_expression} ({column_list})"
1696
+ rendered_model_constraint = (
1697
+ f"{constraint_prefix}unique{constraint_expression} ({column_list})"
1698
+ )
1690
1699
  elif constraint.type == ConstraintType.primary_key:
1691
1700
  constraint_expression = f" {constraint.expression}" if constraint.expression else ""
1692
- return f"{constraint_prefix}primary key{constraint_expression} ({column_list})"
1693
- elif constraint.type == ConstraintType.foreign_key and constraint.expression:
1694
- return f"{constraint_prefix}foreign key ({column_list}) references {constraint.expression}"
1701
+ rendered_model_constraint = (
1702
+ f"{constraint_prefix}primary key{constraint_expression} ({column_list})"
1703
+ )
1704
+ elif constraint.type == ConstraintType.foreign_key:
1705
+ if constraint.to and constraint.to_columns:
1706
+ rendered_model_constraint = f"{constraint_prefix}foreign key ({column_list}) references {constraint.to} ({', '.join(constraint.to_columns)})"
1707
+ elif constraint.expression:
1708
+ rendered_model_constraint = f"{constraint_prefix}foreign key ({column_list}) references {constraint.expression}"
1695
1709
  elif constraint.type == ConstraintType.custom and constraint.expression:
1696
- return f"{constraint_prefix}{constraint.expression}"
1697
- else:
1698
- return None
1710
+ rendered_model_constraint = f"{constraint_prefix}{constraint.expression}"
1711
+
1712
+ return rendered_model_constraint
1699
1713
 
1700
1714
  @classmethod
1701
1715
  def capabilities(cls) -> CapabilityDict:
@@ -0,0 +1,2 @@
1
+ from dbt.adapters.record.handle import RecordReplayHandle
2
+ from dbt.adapters.record.cursor.cursor import RecordReplayCursor
@@ -0,0 +1,54 @@
1
+ from typing import Any, Optional
2
+
3
+ from dbt_common.record import record_function
4
+
5
+ from dbt.adapters.contracts.connection import Connection
6
+ from dbt.adapters.record.cursor.description import CursorGetDescriptionRecord
7
+ from dbt.adapters.record.cursor.execute import CursorExecuteRecord
8
+ from dbt.adapters.record.cursor.fetchone import CursorFetchOneRecord
9
+ from dbt.adapters.record.cursor.fetchmany import CursorFetchManyRecord
10
+ from dbt.adapters.record.cursor.fetchall import CursorFetchAllRecord
11
+ from dbt.adapters.record.cursor.rowcount import CursorGetRowCountRecord
12
+
13
+
14
+ class RecordReplayCursor:
15
+ """A proxy object used to wrap native database cursors under record/replay
16
+ modes. In record mode, this proxy notes the parameters and return values
17
+ of the methods and properties it implements, which closely match the Python
18
+ DB API 2.0 cursor methods used by many dbt adapters to interact with the
19
+ database or DWH. In replay mode, it mocks out those calls using previously
20
+ recorded calls, so that no interaction with a database actually occurs."""
21
+
22
+ def __init__(self, native_cursor: Any, connection: Connection) -> None:
23
+ self.native_cursor = native_cursor
24
+ self.connection = connection
25
+
26
+ @record_function(CursorExecuteRecord, method=True, id_field_name="connection_name")
27
+ def execute(self, operation, parameters=None) -> None:
28
+ self.native_cursor.execute(operation, parameters)
29
+
30
+ @record_function(CursorFetchOneRecord, method=True, id_field_name="connection_name")
31
+ def fetchone(self) -> Any:
32
+ return self.native_cursor.fetchone()
33
+
34
+ @record_function(CursorFetchManyRecord, method=True, id_field_name="connection_name")
35
+ def fetchmany(self, size: int) -> Any:
36
+ return self.native_cursor.fetchmany(size)
37
+
38
+ @record_function(CursorFetchAllRecord, method=True, id_field_name="connection_name")
39
+ def fetchall(self) -> Any:
40
+ return self.native_cursor.fetchall()
41
+
42
+ @property
43
+ def connection_name(self) -> Optional[str]:
44
+ return self.connection.name
45
+
46
+ @property
47
+ @record_function(CursorGetRowCountRecord, method=True, id_field_name="connection_name")
48
+ def rowcount(self) -> int:
49
+ return self.native_cursor.rowcount
50
+
51
+ @property
52
+ @record_function(CursorGetDescriptionRecord, method=True, id_field_name="connection_name")
53
+ def description(self) -> str:
54
+ return self.native_cursor.description
@@ -0,0 +1,37 @@
1
+ import dataclasses
2
+ from typing import Any, Iterable, Mapping
3
+
4
+ from dbt_common.record import Record, Recorder
5
+
6
+
7
+ @dataclasses.dataclass
8
+ class CursorGetDescriptionParams:
9
+ connection_name: str
10
+
11
+
12
+ @dataclasses.dataclass
13
+ class CursorGetDescriptionResult:
14
+ columns: Iterable[Any]
15
+
16
+ def _to_dict(self) -> Any:
17
+ column_dicts = []
18
+ for c in self.columns:
19
+ # This captures the mandatory column information, but we might need
20
+ # more for some adapters.
21
+ # See https://peps.python.org/pep-0249/#description
22
+ column_dicts.append((c[0], c[1]))
23
+
24
+ return {"columns": column_dicts}
25
+
26
+ @classmethod
27
+ def _from_dict(cls, dct: Mapping) -> "CursorGetDescriptionResult":
28
+ return CursorGetDescriptionResult(columns=dct["columns"])
29
+
30
+
31
+ @Recorder.register_record_type
32
+ class CursorGetDescriptionRecord(Record):
33
+ """Implements record/replay support for the cursor.description property."""
34
+
35
+ params_cls = CursorGetDescriptionParams
36
+ result_cls = CursorGetDescriptionResult
37
+ group = "Database"
@@ -0,0 +1,20 @@
1
+ import dataclasses
2
+ from typing import Any, Iterable, Union, Mapping
3
+
4
+ from dbt_common.record import Record, Recorder
5
+
6
+
7
+ @dataclasses.dataclass
8
+ class CursorExecuteParams:
9
+ connection_name: str
10
+ operation: str
11
+ parameters: Union[Iterable[Any], Mapping[str, Any]]
12
+
13
+
14
+ @Recorder.register_record_type
15
+ class CursorExecuteRecord(Record):
16
+ """Implements record/replay support for the cursor.execute() method."""
17
+
18
+ params_cls = CursorExecuteParams
19
+ result_cls = None
20
+ group = "Database"
@@ -0,0 +1,66 @@
1
+ import dataclasses
2
+ import datetime
3
+ from typing import Any, Dict, List, Mapping
4
+
5
+ from dbt_common.record import Record, Recorder
6
+
7
+
8
+ @dataclasses.dataclass
9
+ class CursorFetchAllParams:
10
+ connection_name: str
11
+
12
+
13
+ @dataclasses.dataclass
14
+ class CursorFetchAllResult:
15
+ results: List[Any]
16
+
17
+ def _to_dict(self) -> Dict[str, Any]:
18
+ processed_results = []
19
+ for result in self.results:
20
+ result = tuple(map(self._process_value, result))
21
+ processed_results.append(result)
22
+
23
+ return {"results": processed_results}
24
+
25
+ @classmethod
26
+ def _from_dict(cls, dct: Mapping) -> "CursorFetchAllResult":
27
+ unprocessed_results = []
28
+ for result in dct["results"]:
29
+ result = tuple(map(cls._unprocess_value, result))
30
+ unprocessed_results.append(result)
31
+
32
+ return CursorFetchAllResult(unprocessed_results)
33
+
34
+ @classmethod
35
+ def _process_value(cls, value: Any) -> Any:
36
+ if type(value) is datetime.date:
37
+ return {"type": "date", "value": value.isoformat()}
38
+ elif type(value) is datetime.datetime:
39
+ return {"type": "datetime", "value": value.isoformat()}
40
+ else:
41
+ return value
42
+
43
+ @classmethod
44
+ def _unprocess_value(cls, value: Any) -> Any:
45
+ if type(value) is dict:
46
+ value_type = value.get("type")
47
+ if value_type == "date":
48
+ date_string = value.get("value")
49
+ assert isinstance(date_string, str)
50
+ return datetime.date.fromisoformat(date_string)
51
+ elif value_type == "datetime":
52
+ date_string = value.get("value")
53
+ assert isinstance(date_string, str)
54
+ return datetime.datetime.fromisoformat(date_string)
55
+ return value
56
+ else:
57
+ return value
58
+
59
+
60
+ @Recorder.register_record_type
61
+ class CursorFetchAllRecord(Record):
62
+ """Implements record/replay support for the cursor.fetchall() method."""
63
+
64
+ params_cls = CursorFetchAllParams
65
+ result_cls = CursorFetchAllResult
66
+ group = "Database"
@@ -0,0 +1,23 @@
1
+ import dataclasses
2
+ from typing import Any, List
3
+
4
+ from dbt_common.record import Record, Recorder
5
+
6
+
7
+ @dataclasses.dataclass
8
+ class CursorFetchManyParams:
9
+ connection_name: str
10
+
11
+
12
+ @dataclasses.dataclass
13
+ class CursorFetchManyResult:
14
+ results: List[Any]
15
+
16
+
17
+ @Recorder.register_record_type
18
+ class CursorFetchManyRecord(Record):
19
+ """Implements record/replay support for the cursor.fetchmany() method."""
20
+
21
+ params_cls = CursorFetchManyParams
22
+ result_cls = CursorFetchManyResult
23
+ group = "Database"
@@ -0,0 +1,23 @@
1
+ import dataclasses
2
+ from typing import Any
3
+
4
+ from dbt_common.record import Record, Recorder
5
+
6
+
7
+ @dataclasses.dataclass
8
+ class CursorFetchOneParams:
9
+ connection_name: str
10
+
11
+
12
+ @dataclasses.dataclass
13
+ class CursorFetchOneResult:
14
+ result: Any
15
+
16
+
17
+ @Recorder.register_record_type
18
+ class CursorFetchOneRecord(Record):
19
+ """Implements record/replay support for the cursor.fetchone() method."""
20
+
21
+ params_cls = CursorFetchOneParams
22
+ result_cls = CursorFetchOneResult
23
+ group = "Database"
@@ -0,0 +1,23 @@
1
+ import dataclasses
2
+ from typing import Optional
3
+
4
+ from dbt_common.record import Record, Recorder
5
+
6
+
7
+ @dataclasses.dataclass
8
+ class CursorGetRowCountParams:
9
+ connection_name: str
10
+
11
+
12
+ @dataclasses.dataclass
13
+ class CursorGetRowCountResult:
14
+ rowcount: Optional[int]
15
+
16
+
17
+ @Recorder.register_record_type
18
+ class CursorGetRowCountRecord(Record):
19
+ """Implements record/replay support for the cursor.rowcount property."""
20
+
21
+ params_cls = CursorGetRowCountParams
22
+ result_cls = CursorGetRowCountResult
23
+ group = "Database"
@@ -0,0 +1,24 @@
1
+ from typing import Any
2
+
3
+ from dbt.adapters.contracts.connection import Connection
4
+
5
+ from dbt.adapters.record.cursor.cursor import RecordReplayCursor
6
+
7
+
8
+ class RecordReplayHandle:
9
+ """A proxy object used for record/replay modes. What adapters call a
10
+ 'handle' is typically a native database connection, but should not be
11
+ confused with the Connection protocol, which is a dbt-adapters concept.
12
+
13
+ Currently, the only function of the handle proxy is to provide a record/replay
14
+ aware cursor object when cursor() is called."""
15
+
16
+ def __init__(self, native_handle: Any, connection: Connection) -> None:
17
+ self.native_handle = native_handle
18
+ self.connection = connection
19
+
20
+ def cursor(self) -> Any:
21
+ # The native handle could be None if we are in replay mode, because no
22
+ # actual database access should be performed in that mode.
23
+ cursor = None if self.native_handle is None else self.native_handle.cursor()
24
+ return RecordReplayCursor(cursor, self.connection)
@@ -5,7 +5,6 @@ from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, TYPE_CH
5
5
  from dbt_common.events.contextvars import get_node_info
6
6
  from dbt_common.events.functions import fire_event
7
7
  from dbt_common.exceptions import DbtInternalError, NotImplementedError
8
- from dbt_common.record import record_function
9
8
  from dbt_common.utils import cast_to_str
10
9
 
11
10
  from dbt.adapters.base import BaseConnectionManager
@@ -20,7 +19,6 @@ from dbt.adapters.events.types import (
20
19
  SQLQuery,
21
20
  SQLQueryStatus,
22
21
  )
23
- from dbt.adapters.record import QueryRecord
24
22
 
25
23
  if TYPE_CHECKING:
26
24
  import agate
@@ -143,7 +141,6 @@ class SQLConnectionManager(BaseConnectionManager):
143
141
 
144
142
  return table_from_data_flat(data, column_names)
145
143
 
146
- @record_function(QueryRecord, method=True, tuple_result=True)
147
144
  def execute(
148
145
  self,
149
146
  sql: str,
@@ -61,7 +61,7 @@
61
61
  {% endmacro %}
62
62
 
63
63
  {% macro default__get_show_grant_sql(relation) %}
64
- show grants on {{ relation }}
64
+ show grants on {{ relation.render() }}
65
65
  {% endmacro %}
66
66
 
67
67
 
@@ -70,7 +70,7 @@
70
70
  {% endmacro %}
71
71
 
72
72
  {%- macro default__get_grant_sql(relation, privilege, grantees) -%}
73
- grant {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }}
73
+ grant {{ privilege }} on {{ relation.render() }} to {{ grantees | join(', ') }}
74
74
  {%- endmacro -%}
75
75
 
76
76
 
@@ -79,7 +79,7 @@
79
79
  {% endmacro %}
80
80
 
81
81
  {%- macro default__get_revoke_sql(relation, privilege, grantees) -%}
82
- revoke {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }}
82
+ revoke {{ privilege }} on {{ relation.render() }} from {{ grantees | join(', ') }}
83
83
  {%- endmacro -%}
84
84
 
85
85
 
@@ -147,7 +147,7 @@
147
147
  {% set needs_granting = diff_of_two_dicts(grant_config, current_grants_dict) %}
148
148
  {% set needs_revoking = diff_of_two_dicts(current_grants_dict, grant_config) %}
149
149
  {% if not (needs_granting or needs_revoking) %}
150
- {{ log('On ' ~ relation ~': All grants are in place, no revocation or granting needed.')}}
150
+ {{ log('On ' ~ relation.render() ~': All grants are in place, no revocation or granting needed.')}}
151
151
  {% endif %}
152
152
  {% else %}
153
153
  {#-- We don't think there's any chance of previous grants having carried over. --#}
@@ -96,10 +96,10 @@
96
96
  {%- set tmp_column = column_name + "__dbt_alter" -%}
97
97
 
98
98
  {% call statement('alter_column_type') %}
99
- alter table {{ relation }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};
100
- update {{ relation }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};
101
- alter table {{ relation }} drop column {{ adapter.quote(column_name) }} cascade;
102
- alter table {{ relation }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}
99
+ alter table {{ relation.render() }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};
100
+ update {{ relation.render() }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};
101
+ alter table {{ relation.render() }} drop column {{ adapter.quote(column_name) }} cascade;
102
+ alter table {{ relation.render() }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}
103
103
  {% endcall %}
104
104
 
105
105
  {% endmacro %}
@@ -120,7 +120,7 @@
120
120
 
121
121
  {% set sql -%}
122
122
 
123
- alter {{ relation.type }} {{ relation }}
123
+ alter {{ relation.type }} {{ relation.render() }}
124
124
 
125
125
  {% for column in add_columns %}
126
126
  add column {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}
@@ -38,7 +38,7 @@
38
38
 
39
39
  {% macro default__truncate_relation(relation) -%}
40
40
  {% call statement('truncate_relation') -%}
41
- truncate table {{ relation }}
41
+ truncate table {{ relation.render() }}
42
42
  {%- endcall %}
43
43
  {% endmacro %}
44
44
 
@@ -1,22 +1,26 @@
1
+ {#
2
+ We expect a syntax error if dbt show is invoked both with a --limit flag to show
3
+ and with a limit predicate embedded in its inline query. No special handling is
4
+ provided out-of-box.
5
+ #}
1
6
  {% macro get_show_sql(compiled_code, sql_header, limit) -%}
2
- {%- if sql_header -%}
7
+ {%- if sql_header is not none -%}
3
8
  {{ sql_header }}
4
- {%- endif -%}
5
- {%- if limit is not none -%}
9
+ {%- endif %}
6
10
  {{ get_limit_subquery_sql(compiled_code, limit) }}
7
- {%- else -%}
8
- {{ compiled_code }}
9
- {%- endif -%}
10
11
  {% endmacro %}
11
12
 
12
- {% macro get_limit_subquery_sql(sql, limit) %}
13
- {{ adapter.dispatch('get_limit_subquery_sql', 'dbt')(sql, limit) }}
14
- {% endmacro %}
13
+ {#
14
+ Not necessarily a true subquery anymore. Now, merely a query subordinate
15
+ to the calling macro.
16
+ #}
17
+ {%- macro get_limit_subquery_sql(sql, limit) -%}
18
+ {{ adapter.dispatch('get_limit_sql', 'dbt')(sql, limit) }}
19
+ {%- endmacro -%}
15
20
 
16
- {% macro default__get_limit_subquery_sql(sql, limit) %}
17
- select *
18
- from (
19
- {{ sql }}
20
- ) as model_limit_subq
21
- limit {{ limit }}
21
+ {% macro default__get_limit_sql(sql, limit) %}
22
+ {{ compiled_code }}
23
+ {% if limit is not none %}
24
+ limit {{ limit }}
25
+ {%- endif -%}
22
26
  {% endmacro %}
@@ -27,14 +27,14 @@
27
27
 
28
28
  {%- set target_relation = this.incorporate(type='table') -%}
29
29
  {% if existing_relation is not none and not existing_relation.is_table %}
30
- {{ log("Dropping relation " ~ existing_relation ~ " because it is of type " ~ existing_relation.type) }}
30
+ {{ log("Dropping relation " ~ existing_relation.render() ~ " because it is of type " ~ existing_relation.type) }}
31
31
  {{ drop_relation_if_exists(existing_relation) }}
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
35
  {% call statement('main') %}
36
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) }}
37
+ {{ log("Target relation and defer relation are the same, skipping clone for relation: " ~ target_relation.render()) }}
38
38
  {% else %}
39
39
  {{ create_or_replace_clone(target_relation, defer_relation) }}
40
40
  {% endif %}
@@ -3,5 +3,5 @@
3
3
  {% endmacro %}
4
4
 
5
5
  {% macro default__create_or_replace_clone(this_relation, defer_relation) %}
6
- create or replace table {{ this_relation }} clone {{ defer_relation }}
6
+ create or replace table {{ this_relation.render() }} clone {{ defer_relation.render() }}
7
7
  {% endmacro %}
@@ -39,9 +39,12 @@
39
39
  {% set need_swap = true %}
40
40
  {% else %}
41
41
  {% do run_query(get_create_table_as_sql(True, temp_relation, sql)) %}
42
- {% do adapter.expand_target_column_types(
43
- from_relation=temp_relation,
44
- to_relation=target_relation) %}
42
+ {% set contract_config = config.get('contract') %}
43
+ {% if not contract_config or not contract_config.enforced %}
44
+ {% do adapter.expand_target_column_types(
45
+ from_relation=temp_relation,
46
+ to_relation=target_relation) %}
47
+ {% endif %}
45
48
  {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}
46
49
  {% set dest_columns = process_schema_changes(on_schema_change, temp_relation, existing_relation) %}
47
50
  {% if not dest_columns %}
@@ -71,9 +71,9 @@
71
71
  {% set build_sql = get_alter_materialized_view_as_sql(target_relation, configuration_changes, sql, existing_relation, backup_relation, intermediate_relation) %}
72
72
  {% elif on_configuration_change == 'continue' %}
73
73
  {% set build_sql = '' %}
74
- {{ exceptions.warn("Configuration changes were identified and `on_configuration_change` was set to `continue` for `" ~ target_relation ~ "`") }}
74
+ {{ exceptions.warn("Configuration changes were identified and `on_configuration_change` was set to `continue` for `" ~ target_relation.render() ~ "`") }}
75
75
  {% elif on_configuration_change == 'fail' %}
76
- {{ exceptions.raise_fail_fast_error("Configuration changes were identified and `on_configuration_change` was set to `fail` for `" ~ target_relation ~ "`") }}
76
+ {{ exceptions.raise_fail_fast_error("Configuration changes were identified and `on_configuration_change` was set to `fail` for `" ~ target_relation.render() ~ "`") }}
77
77
 
78
78
  {% else %}
79
79
  -- this only happens if the user provides a value other than `apply`, 'skip', 'fail'
@@ -37,7 +37,7 @@
37
37
  {% set sql = create_csv_table(model, agate_table) %}
38
38
  {% else %}
39
39
  {{ adapter.truncate_relation(old_relation) }}
40
- {% set sql = "truncate table " ~ old_relation %}
40
+ {% set sql = "truncate table " ~ old_relation.render() %}
41
41
  {% endif %}
42
42
 
43
43
  {{ return(sql) }}
@@ -22,7 +22,7 @@
22
22
  -- build model
23
23
  {% set create_table_sql = "" %}
24
24
  {% if exists_as_view %}
25
- {{ exceptions.raise_compiler_error("Cannot seed to '{}', it is a view".format(old_relation)) }}
25
+ {{ exceptions.raise_compiler_error("Cannot seed to '{}', it is a view".format(old_relation.render())) }}
26
26
  {% elif exists_as_table %}
27
27
  {% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}
28
28
  {% else %}
@@ -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 }} add column "{{ column.name }}" {{ column.data_type }};
11
+ alter table {{ relation.render() }} add column "{{ column.name }}" {{ column.data_type }};
12
12
  {% endcall %}
13
13
  {% endfor %}
14
14
  {% endmacro %}
@@ -7,7 +7,7 @@
7
7
  {% macro default__snapshot_merge_sql(target, source, insert_cols) -%}
8
8
  {%- set insert_cols_csv = insert_cols | join(', ') -%}
9
9
 
10
- merge into {{ target }} as DBT_INTERNAL_DEST
10
+ merge into {{ target.render() }} as DBT_INTERNAL_DEST
11
11
  using {{ source }} as DBT_INTERNAL_SOURCE
12
12
  on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id
13
13
 
@@ -16,7 +16,7 @@
16
16
  {{ drop_materialized_view(relation) }}
17
17
 
18
18
  {%- else -%}
19
- drop {{ relation.type }} if exists {{ relation }} cascade
19
+ drop {{ relation.type }} if exists {{ relation.render() }} cascade
20
20
 
21
21
  {%- endif -%}
22
22
 
@@ -10,5 +10,5 @@ actually executes the drop, and `get_drop_sql`, which returns the template.
10
10
 
11
11
 
12
12
  {% macro default__drop_materialized_view(relation) -%}
13
- drop materialized view if exists {{ relation }} cascade
13
+ drop materialized view if exists {{ relation.render() }} cascade
14
14
  {%- endmacro %}
@@ -30,6 +30,6 @@
30
30
  {% macro default__rename_relation(from_relation, to_relation) -%}
31
31
  {% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}
32
32
  {% call statement('rename_relation') -%}
33
- alter table {{ from_relation }} rename to {{ target_name }}
33
+ alter table {{ from_relation.render() }} rename to {{ target_name }}
34
34
  {%- endcall %}
35
35
  {% endmacro %}
@@ -10,5 +10,5 @@ actually executes the drop, and `get_drop_sql`, which returns the template.
10
10
 
11
11
 
12
12
  {% macro default__drop_table(relation) -%}
13
- drop table if exists {{ relation }} cascade
13
+ drop table if exists {{ relation.render() }} cascade
14
14
  {%- endmacro %}
@@ -16,7 +16,7 @@
16
16
  {%- set sql_header = config.get('sql_header', none) -%}
17
17
 
18
18
  {{ sql_header if sql_header is not none }}
19
- create view {{ relation }}
19
+ create view {{ relation.render() }}
20
20
  {% set contract_config = config.get('contract') %}
21
21
  {% if contract_config.enforced %}
22
22
  {{ get_assert_columns_equivalent(sql) }}
@@ -10,5 +10,5 @@ actually executes the drop, and `get_drop_sql`, which returns the template.
10
10
 
11
11
 
12
12
  {% macro default__drop_view(relation) -%}
13
- drop view if exists {{ relation }} cascade
13
+ drop view if exists {{ relation.render() }} cascade
14
14
  {%- endmacro %}
@@ -61,6 +61,6 @@
61
61
  {% endmacro %}
62
62
 
63
63
  {% macro default__handle_existing_table(full_refresh, old_relation) %}
64
- {{ log("Dropping relation " ~ old_relation ~ " because it is of type " ~ old_relation.type) }}
64
+ {{ log("Dropping relation " ~ old_relation.render() ~ " because it is of type " ~ old_relation.type) }}
65
65
  {{ adapter.drop_relation(old_relation) }}
66
66
  {% endmacro %}
@@ -22,6 +22,7 @@
22
22
  {%- do default_row.update({column_name: (safe_cast("null", column_type) | trim )}) -%}
23
23
  {%- endfor -%}
24
24
 
25
+ {{ validate_fixture_rows(rows, row_number) }}
25
26
 
26
27
  {%- for row in rows -%}
27
28
  {%- set formatted_row = format_row(row, column_name_to_data_types) -%}
@@ -93,3 +94,11 @@ union all
93
94
  {%- endfor -%}
94
95
  {{ return(formatted_row) }}
95
96
  {%- endmacro -%}
97
+
98
+ {%- macro validate_fixture_rows(rows, row_number) -%}
99
+ {{ return(adapter.dispatch('validate_fixture_rows', 'dbt')(rows, row_number)) }}
100
+ {%- endmacro -%}
101
+
102
+ {%- macro default__validate_fixture_rows(rows, row_number) -%}
103
+ {# This is an abstract method for adapter overrides as needed #}
104
+ {%- endmacro -%}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dbt-adapters
3
- Version: 1.3.2
3
+ Version: 1.4.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
6
6
  Project-URL: Documentation, https://docs.getdbt.com
@@ -11,7 +11,7 @@ Author-email: dbt Labs <info@dbtlabs.com>
11
11
  Maintainer-email: dbt Labs <info@dbtlabs.com>
12
12
  License-File: LICENSE
13
13
  Keywords: adapter,adapters,database,dbt,dbt Cloud,dbt Core,dbt Labs,dbt-core,elt
14
- Classifier: Development Status :: 2 - Pre-Alpha
14
+ Classifier: Development Status :: 5 - Production/Stable
15
15
  Classifier: License :: OSI Approved :: Apache Software License
16
16
  Classifier: Operating System :: MacOS :: MacOS X
17
17
  Classifier: Operating System :: Microsoft :: Windows
@@ -23,7 +23,7 @@ Classifier: Programming Language :: Python :: 3.11
23
23
  Classifier: Programming Language :: Python :: 3.12
24
24
  Requires-Python: >=3.8.0
25
25
  Requires-Dist: agate<2.0,>=1.0
26
- Requires-Dist: dbt-common<2.0,>=1.3
26
+ Requires-Dist: dbt-common<2.0,>=1.6
27
27
  Requires-Dist: mashumaro[msgpack]<4.0,>=3.0
28
28
  Requires-Dist: protobuf<5.0,>=3.0
29
29
  Requires-Dist: pytz>=2015.7
@@ -1,19 +1,18 @@
1
1
  dbt/__init__.py,sha256=iY4jdvOxcDhkdr5FiyOTZPHadKtMZDQ-qC6Fw6_EHPM,277
2
- dbt/adapters/__about__.py,sha256=d_9qKGE8SF0PKp68I9vjmi62C9Vy9vqYwA_w4aWUwZM,18
2
+ dbt/adapters/__about__.py,sha256=0kccNYBMuNA3PIhlESWmh8xP1TWpNtIEzS0d-x80SC0,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
6
6
  dbt/adapters/factory.py,sha256=JxNxhMqemZ6ARWbROQZhkhJehiIenuR9ZQYS8gvzbDg,9368
7
7
  dbt/adapters/protocol.py,sha256=qRsEFAKjUMVnoBspAiCUTICez1ckson-dFS04dTXSco,3818
8
8
  dbt/adapters/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- dbt/adapters/record.py,sha256=D7fa0wh2QSM4Xp3uhiM6fpsLN6F0mIQHwDaT7D22pfo,1972
10
9
  dbt/adapters/reference_keys.py,sha256=lRN3gPdQD6Qciy-BAGx_rz3CFlbS7zMSZ43pZ_9ondE,1046
11
10
  dbt/adapters/utils.py,sha256=OtakbxPgxwrxN5Yd2vAO-cvLETSgzBwMWebhgegAVyA,2414
12
11
  dbt/adapters/base/README.md,sha256=muHQntC07Lh6L1XfVgwKhV5RltOPBLYPdQqd8_7l34c,516
13
12
  dbt/adapters/base/__init__.py,sha256=KGGGbj8jGMjAFJdQ5YHcOpApMMVZ_6Xuni1swhpkqRY,423
14
- dbt/adapters/base/column.py,sha256=M3iotEY5yi4xikXyXzD9oshBF9-xcJrIeQVu1sB85DI,5450
13
+ dbt/adapters/base/column.py,sha256=Uj20UixoxCn2rlv4QDNONyys6CDkDFyG3anCXKf0T2c,5350
15
14
  dbt/adapters/base/connections.py,sha256=-C5dOwGgMKH8n_v6wjwOxV7chBdS0GjOGwNQCUbhhWc,16951
16
- dbt/adapters/base/impl.py,sha256=Z0rdtNs-XQC_fhnfqtTLOj2-mSFIa0m-6XiVb0S8VPg,68879
15
+ dbt/adapters/base/impl.py,sha256=oRkaEUjLWLlisyLpxpjddDj7j0mjh5OWXwVgT0h6y14,69552
17
16
  dbt/adapters/base/meta.py,sha256=MMqL2xBqdvoacNs9JcL0E38NZIhCP4RH4OD_z_jo7GQ,4644
18
17
  dbt/adapters/base/plugin.py,sha256=rm0GjNHnWM2mn0GJOjciZLwn-02xlzWCoMT9u-epwP0,1076
19
18
  dbt/adapters/base/query_headers.py,sha256=UluGd9IYCYkoMiDi5Yx_lnrCOSjWppjwRro4SIGgx8I,3496
@@ -37,28 +36,37 @@ dbt/adapters/exceptions/cache.py,sha256=u720DQQKm8pyf_9loD9HGA9WgaeZAlg0sBn0sGc-
37
36
  dbt/adapters/exceptions/compilation.py,sha256=KAiCwxyE1B3PrxU-aHvpJp4h6fgEcZf44h4iVz__jFY,8586
38
37
  dbt/adapters/exceptions/connection.py,sha256=x82j2Ix242Slm6Ima8Tol3GLOB9yZYH5lq6IV1WKq54,445
39
38
  dbt/adapters/exceptions/database.py,sha256=nIXJdQyPQOZaiKvCkQ3MoKlKOiaN58rtDZflw3CSkug,1618
39
+ dbt/adapters/record/__init__.py,sha256=u_0eJzN5RL90oL-RNoP2wWGMCGp0kG0lZ0uVWnnGdxs,123
40
+ dbt/adapters/record/handle.py,sha256=mDsaNHZkUZMaLSg6QHSE11dbTrSLtfg9GRMcw2c2KAI,1011
41
+ dbt/adapters/record/cursor/cursor.py,sha256=rhk50XhOAWa4r1POSrb4-TX6MjJ-mwZfDsADxI41NYk,2412
42
+ dbt/adapters/record/cursor/description.py,sha256=5LNebP2AF2aicPWfM9FsD5r7SAmdac8TX_4NZfJQgPk,1060
43
+ dbt/adapters/record/cursor/execute.py,sha256=Y9HUVteOFbDtJJjZPQLny8UgKSs2OgNa19FS7w1bGRE,495
44
+ dbt/adapters/record/cursor/fetchall.py,sha256=YeDTh4DU-Iqw9hCoJfqlrgHq2hhhwpIi1Zxx_KU0M6U,2057
45
+ dbt/adapters/record/cursor/fetchmany.py,sha256=6PTkVa6xZs1g3M4OdqFrnrF9x0vrNJyVNk6rLbhd_Mg,502
46
+ dbt/adapters/record/cursor/fetchone.py,sha256=IKtzTMQjSeK3g0svtWMXLx_7OGx6HpbPh1zicuOqARA,483
47
+ dbt/adapters/record/cursor/rowcount.py,sha256=BuiRd_JpQTPN3YaGACfsXe1vmsvO4c49kCpIBZoG6hE,515
40
48
  dbt/adapters/relation_configs/README.md,sha256=VVeqMLbBWsBVNXHa9GLKLBN25Ivc8y78GR-6OB2tf4U,1809
41
49
  dbt/adapters/relation_configs/__init__.py,sha256=Il1HHEI8HJGHEi2B8qsgv_CoNA2STO7SULDi78fQwZg,354
42
50
  dbt/adapters/relation_configs/config_base.py,sha256=IK9oKf9TuOTLIiKX8ms_X-p4yxZvPAlM7qg94mozvrA,1756
43
51
  dbt/adapters/relation_configs/config_change.py,sha256=hf6fDWbZpKvZdM6z-OtY-GveipzfLRR_dsUZmYmXkdk,713
44
52
  dbt/adapters/relation_configs/config_validation.py,sha256=wlJUMwOEPhYFch-LRtEWfLNJMq8jL1tRhOUHmNX8nFw,1978
45
53
  dbt/adapters/sql/__init__.py,sha256=WLWZJfqc8pr1N1BMVe9gM-KQ4URJIeKfLqTuJBD1VN0,107
46
- dbt/adapters/sql/connections.py,sha256=ASxZtpPoM_EtmD_nfG0z5F8pTO5YsWfUBV7QKqx4cec,6628
54
+ dbt/adapters/sql/connections.py,sha256=JYML3G9Ro2rTa0Q5IujKaNzpiPRGrUDuzQH0qej7SmE,6472
47
55
  dbt/adapters/sql/impl.py,sha256=HmH3eC-qVeCAAukjEOnUNZbH-UK32X-NL4kwb_EHzs0,10763
48
56
  dbt/include/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3hk,76
49
57
  dbt/include/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
58
  dbt/include/global_project/__init__.py,sha256=-0HL5OkeJSrxglm1Y-UltTiBPY2BbWx8ZpTiJ7ypSvw,73
51
59
  dbt/include/global_project/dbt_project.yml,sha256=RTtOhnBpEL0gbd1GlpxuVr6eZJBPvgWfNw-F88sKQ-w,109
52
60
  dbt/include/global_project/docs/overview.md,sha256=VuObM4pcS-TvwYeAjjUbe0TBhEnxf6g30EPWrGjya_w,1824
53
- dbt/include/global_project/macros/adapters/apply_grants.sql,sha256=Vyb0VNmlgoXzE1Dh2myVjujztM8VX06t3h9wGceMEeQ,6825
54
- dbt/include/global_project/macros/adapters/columns.sql,sha256=EUze4gUUDD1pnWytOpjk3p-7EFpqeqeI0LiPf2FbUVo,5438
61
+ dbt/include/global_project/macros/adapters/apply_grants.sql,sha256=3NUJLWmNE0ZAWxc1LuIpo6-dTfLEBjX1Os5BdDb_IOQ,6861
62
+ dbt/include/global_project/macros/adapters/columns.sql,sha256=21cb0Q8A3oDbajV7oL06arDcmg-YuvWRmQ-07KeI-dk,5483
55
63
  dbt/include/global_project/macros/adapters/freshness.sql,sha256=FKi-xsBCOYjGYp103O1mVTeWKy2blb_JefyoLDF0aXI,599
56
64
  dbt/include/global_project/macros/adapters/indexes.sql,sha256=DasPn32Cm0OZyjBPBWzL4BpK9PZ3xF_Pu8Nh4NgASaw,1366
57
65
  dbt/include/global_project/macros/adapters/metadata.sql,sha256=meNIc3z4lXdh1lDb-K1utKb8VzAVuN23E6XWgMZGDhQ,3512
58
66
  dbt/include/global_project/macros/adapters/persist_docs.sql,sha256=TUazJHSaMIDlELqALLRMC2kYj5DGZ9U-6K8RbgwRXw4,1369
59
- dbt/include/global_project/macros/adapters/relation.sql,sha256=RyUZAAGCQHU6YA43_5-zApp2PcvGTgLMXg61sqhe5vc,2800
67
+ dbt/include/global_project/macros/adapters/relation.sql,sha256=18lE088vj0JZW8af2byoGLFhxYxekyXKTrX7Dj-B-E0,2809
60
68
  dbt/include/global_project/macros/adapters/schema.sql,sha256=XElo0cfvdEipI5hpulLXLBEXP_YnilG-1kRwDMqDD5I,594
61
- dbt/include/global_project/macros/adapters/show.sql,sha256=_KdykFha7eiEl0D_NFfYHGFjywccii7rvy0h-GffVr4,566
69
+ dbt/include/global_project/macros/adapters/show.sql,sha256=mFDQZxvvDzafTeh9v90ttks-VCjUUxbrw_YA02MV1Jk,785
62
70
  dbt/include/global_project/macros/adapters/timestamps.sql,sha256=V_vM-UWyKGGs7rP4DumBgZrbb-TkucIFEvMn69Zpaxg,1482
63
71
  dbt/include/global_project/macros/adapters/validate_sql.sql,sha256=IC-HEVv8Cl8nd7dic_U4hyqlrkdO6plPbH914OdM_WE,285
64
72
  dbt/include/global_project/macros/etc/datetime.sql,sha256=HwNxXw0xHHLVKFBlbbc4wqTdYe6_smku1EwWGM7G-6g,2185
@@ -72,23 +80,23 @@ dbt/include/global_project/macros/get_custom_name/get_custom_database.sql,sha256
72
80
  dbt/include/global_project/macros/get_custom_name/get_custom_schema.sql,sha256=2-ZYuDRBo2RSCKZTX7rzm2Y77DVCaHGTnHG9IKNMpvk,1731
73
81
  dbt/include/global_project/macros/materializations/configs.sql,sha256=aciTDXFQoiAU4y8nsreTQnSca18P2tjURx-LQIrzyuc,627
74
82
  dbt/include/global_project/macros/materializations/hooks.sql,sha256=IIOLRanrLtpYcWxWPaPJ7JMoyJdQJicEDni4yoE9mJI,994
75
- dbt/include/global_project/macros/materializations/models/materialized_view.sql,sha256=qReMYPA6_w_b49_w6qHiEiTGD-M-xgUc22jh04PAeIg,5011
83
+ dbt/include/global_project/macros/materializations/models/materialized_view.sql,sha256=-u0cGQrHEMBt8coXfKKPpUQJS97TX3QRafV873fqeCA,5029
76
84
  dbt/include/global_project/macros/materializations/models/table.sql,sha256=wkpW8tmsIpfU5nOKqk1rtYhLcOGokFjCvLP2qQ5SbOk,2676
77
85
  dbt/include/global_project/macros/materializations/models/view.sql,sha256=LPqM3aTsWiAalFz322aTpqKqCdl4hxN8ubcwXZIIDDw,3249
78
86
  dbt/include/global_project/macros/materializations/models/clone/can_clone_table.sql,sha256=YVq2f574IxMDuEv5rbaTvUpLLqc-jQfyOgBQJQGWcmk,187
79
- dbt/include/global_project/macros/materializations/models/clone/clone.sql,sha256=gZPp7_Kd9fminkQob6OzJ_S_RsE6PhfSyRjaSmkVEC8,2698
80
- dbt/include/global_project/macros/materializations/models/clone/create_or_replace_clone.sql,sha256=7MQuii-8WbUZs3zXcBcNOB6dgWmfEyUDZGgyp8_-3Yk,349
87
+ dbt/include/global_project/macros/materializations/models/clone/clone.sql,sha256=X85U0zwq_OINxeZ7JDer9i3BgQZvgGM-tKTvITrQx5s,2716
88
+ dbt/include/global_project/macros/materializations/models/clone/create_or_replace_clone.sql,sha256=qr33DwFOpRG0wGVsGvr63-MexYMNZC9xKdGOPmICp_c,367
81
89
  dbt/include/global_project/macros/materializations/models/incremental/column_helpers.sql,sha256=hslQlGKW0oW97srfugsFVRR-L6RrzRcnwr3uLhzI0X4,2577
82
- dbt/include/global_project/macros/materializations/models/incremental/incremental.sql,sha256=rUgR9ibjgw8ZFgbnZOKPW0Vv-G1shQ1FelPc7GWmkuA,4235
90
+ dbt/include/global_project/macros/materializations/models/incremental/incremental.sql,sha256=sS8XtG-T_-Gn1tCjSTFSlmJqkgu08-upWEs_UJ_RfXI,4377
83
91
  dbt/include/global_project/macros/materializations/models/incremental/is_incremental.sql,sha256=Sm1TqOeqcCQofj3REFcA97yukPB1J_mClDd55r5GewE,478
84
92
  dbt/include/global_project/macros/materializations/models/incremental/merge.sql,sha256=Xg5-Gc9jHego-wpdfg6yEIQv7EClz6-xcJEeFXuZiwQ,5197
85
93
  dbt/include/global_project/macros/materializations/models/incremental/on_schema_change.sql,sha256=EOgcrYhwOGVPnyaBu7kIfe8LTOYVOu-AhxMtBs8ETpQ,4927
86
94
  dbt/include/global_project/macros/materializations/models/incremental/strategies.sql,sha256=1QKXoCm47g_JAmWypjSUHU8ACmXFgaBoWUG3HPCN7wA,2251
87
- dbt/include/global_project/macros/materializations/seeds/helpers.sql,sha256=jJB1i8z4PhxQP_DTUze6xpR_PXHQ8dhJ25TNqy0GQkA,3911
88
- dbt/include/global_project/macros/materializations/seeds/seed.sql,sha256=lO-SJ3rpwE-MIZD7dAvhjXUgPya11Vmm79MLE5Xf8-U,2146
89
- dbt/include/global_project/macros/materializations/snapshots/helpers.sql,sha256=taUIQ0hybn8kIvA6lMZcdvTw8yrYJo1RhpiP8EqlRfo,4807
95
+ dbt/include/global_project/macros/materializations/seeds/helpers.sql,sha256=Y15ej-D3gm1ExIOMNT208q43gRk8d985WQBuGSooNL0,3920
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=O0aCMTPUrFONwEamKu7AMuUP6Tp0-NegJf6aZnS1018,4816
90
98
  dbt/include/global_project/macros/materializations/snapshots/snapshot.sql,sha256=q-Uaz9B2070fpruz5HEJiCqPUJNgXl7dsM5a0_v0fkg,3680
91
- dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql,sha256=Ik3OyDqqkt0z4lrNUvMKYVmZxqAdtaN1FvtMgg0VF6g,849
99
+ dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql,sha256=Lu3Yq3fEQuOGoDY0NFfruTAuvOEF3wXuo3SF_dK7uqY,858
92
100
  dbt/include/global_project/macros/materializations/snapshots/strategies.sql,sha256=ahWDMnD-Q_fTGKSjvm5ZwvypmNC6BDVguk-LNk-nHhU,6286
93
101
  dbt/include/global_project/macros/materializations/tests/helpers.sql,sha256=rxUxDZm4EvrDbi0H_ePghE34_QLmxGEY2o_LTMc9CU0,1731
94
102
  dbt/include/global_project/macros/materializations/tests/test.sql,sha256=Rz3O_3dWHlIofG3d2CwsP2bXFimRZUIwOevyB0iz1J4,1831
@@ -98,28 +106,28 @@ dbt/include/global_project/macros/python_model/python.sql,sha256=OKy-IwnklJPXfjX
98
106
  dbt/include/global_project/macros/relations/create.sql,sha256=99LLak1bhlhRw7yiI0c_4CKPlGyzqPBeBYBNeBPSmDo,701
99
107
  dbt/include/global_project/macros/relations/create_backup.sql,sha256=jAWJSw3BUxvYrjgBs3JkRJN_VHXtk05lMWPM4n-toWs,524
100
108
  dbt/include/global_project/macros/relations/create_intermediate.sql,sha256=bgPogZqRykUrdRxo_kvoKLrJ9C2x1c_TvtUZlYwUfmQ,568
101
- dbt/include/global_project/macros/relations/drop.sql,sha256=K-EFkOfb-fWf7eZ73Y5H5Iitv4jQ1_IM8cLcDhrHRiM,1020
109
+ dbt/include/global_project/macros/relations/drop.sql,sha256=UL40SxBjHLPpIHywKYHZQswEhepH1YIPh0VJ5UPAwaU,1029
102
110
  dbt/include/global_project/macros/relations/drop_backup.sql,sha256=PTbx_bN27aqCv9HD9I7Td5rJaRrH23TXDs9aC5ei8Q8,415
103
- dbt/include/global_project/macros/relations/rename.sql,sha256=n1Ic_F6okFEzUXvVq9Fj5Q1LNK_Ld2F9FI_FO3t5yFo,1174
111
+ dbt/include/global_project/macros/relations/rename.sql,sha256=0YLUnZtov5FOtr-j7CjI4LNtXWojWGER2q1lVbJMH5c,1183
104
112
  dbt/include/global_project/macros/relations/rename_intermediate.sql,sha256=rhcK6jeo5gfQ-1rqFd2lyTT4HtAzu8Ndzbz2FzHMBhs,479
105
113
  dbt/include/global_project/macros/relations/replace.sql,sha256=9SonmERpKBkqHJCnyJmxjPnhGiKfxuysNszAMgYIGSE,2295
106
114
  dbt/include/global_project/macros/relations/schema.sql,sha256=kOQeEZQwycGGtAoq_KM6EyvEhquFk8jnx81nT31s58M,318
107
115
  dbt/include/global_project/macros/relations/column/columns_spec_ddl.sql,sha256=ukW4iLuAXYfsrnlfeY26cFMMFxATcNV8hlp9valOx8U,3676
108
116
  dbt/include/global_project/macros/relations/materialized_view/alter.sql,sha256=pZcZa1xfcZZpVVSvvJ3YR0zn6noIKBfkTSbrqKohAcU,1806
109
117
  dbt/include/global_project/macros/relations/materialized_view/create.sql,sha256=C8BpyEhxETU3N46I4WNoCwB0fTb3aOhJj6EfTkNoTd0,400
110
- dbt/include/global_project/macros/relations/materialized_view/drop.sql,sha256=tYCwNlcoH8RmqkIumioO7nmhWWAVcwDIfly5Z7PGh3g,540
118
+ dbt/include/global_project/macros/relations/materialized_view/drop.sql,sha256=tNApIdMA2lAFfj02lNJJ5Oo7KXwc7qzOSFdm_jbXy-o,549
111
119
  dbt/include/global_project/macros/relations/materialized_view/refresh.sql,sha256=tTHxhzHp8mLziJgzTm7nkooC5-fAlsClOf_9-kMR794,380
112
120
  dbt/include/global_project/macros/relations/materialized_view/rename.sql,sha256=E1IQoaocaV2bt-vAYwBwAevSRaSsRisCZBY-l9dk_-Y,400
113
121
  dbt/include/global_project/macros/relations/materialized_view/replace.sql,sha256=WxbFchYzHVulEhdPa0crFoID3GR17Hw_mFdcyGKs7f0,389
114
122
  dbt/include/global_project/macros/relations/table/create.sql,sha256=-IKYB4GC1_YmGIiJ-AKUkfvq8UCvd5Exe91ojt0r41o,2140
115
- dbt/include/global_project/macros/relations/table/drop.sql,sha256=SvXZX3OLNB8oGYmfZ83eHsIWiOLyyuS9Po6Dr6g4oa8,492
123
+ dbt/include/global_project/macros/relations/table/drop.sql,sha256=E-6dxRC5_z52mvVTJRcnhih2YduKK-wouIwEvu1S8-E,501
116
124
  dbt/include/global_project/macros/relations/table/rename.sql,sha256=GMmz83Sius6Y3fPdlnjMYXrVRDP8INO6tLAn3vfgzYI,352
117
125
  dbt/include/global_project/macros/relations/table/replace.sql,sha256=xlTB2pI_fEkAPJdmbrirSrnzvFYTPtz9ROMCMxANFCo,341
118
- dbt/include/global_project/macros/relations/view/create.sql,sha256=FkLYXnCPj2HLCbtN47KR45L6hFxqPiBLcSPCfs0v2YU,839
119
- dbt/include/global_project/macros/relations/view/drop.sql,sha256=WszUTZrkd93_OCEha4OuRWyCucqxGRTm07Zvn25RHXs,488
126
+ dbt/include/global_project/macros/relations/view/create.sql,sha256=VXIsJWo4OZ_8kpoey08wGIWPUYaw2utQVChOGeMt7Lk,848
127
+ dbt/include/global_project/macros/relations/view/drop.sql,sha256=iFjhEwzip00TGd8h6T5UsXo4dK440EvgdKwR_j4XX78,497
120
128
  dbt/include/global_project/macros/relations/view/rename.sql,sha256=P4hpxlrR0wiBTZFJ8N3GyUUbqgKgMfgzUUbIWw8fui0,348
121
- dbt/include/global_project/macros/relations/view/replace.sql,sha256=5_Lky7KUixyYOOOahooD0VnmHOiOVqmxrI0ihwRjX08,2584
122
- dbt/include/global_project/macros/unit_test_sql/get_fixture_sql.sql,sha256=lV-dTZmQQSl3YePl3fWqUF1Ntw5bYEzuNtJFby1JrMc,3873
129
+ dbt/include/global_project/macros/relations/view/replace.sql,sha256=cLqNkmTxAxsJS8g-dj4K6IikpjDGKlyCECA3nerPMzg,2593
130
+ dbt/include/global_project/macros/unit_test_sql/get_fixture_sql.sql,sha256=cNZhMdNOFBGftr9ij_2TY_GCUaKGMU5YVTcIb5jHBpo,4222
123
131
  dbt/include/global_project/macros/utils/any_value.sql,sha256=leK-fCUhDNt6MFkGofafYjv-0LtL0fkb3sJXe-aIorU,213
124
132
  dbt/include/global_project/macros/utils/array_append.sql,sha256=XsC-kchlWxVwc-_1CoBs1RkGYt8qsOAVbq5JlsV2WIc,357
125
133
  dbt/include/global_project/macros/utils/array_concat.sql,sha256=0c4w5kP1N_9BY-wppx1OBCCIDOsC1HhimkSDghjjx2Y,248
@@ -149,7 +157,7 @@ dbt/include/global_project/macros/utils/right.sql,sha256=EwNG98CAFIwNDmarwopf7Rk
149
157
  dbt/include/global_project/macros/utils/safe_cast.sql,sha256=1mswwkDACmIi1I99JKb_-vq3kjMe4HhMRV70mW8Bt4Y,298
150
158
  dbt/include/global_project/macros/utils/split_part.sql,sha256=fXEIS0oIiYR7-4lYbb0QbZdG-q2TpV63AFd1ky4I5UM,714
151
159
  dbt/include/global_project/tests/generic/builtin.sql,sha256=p94xdyPwb2TlxgLBqCfrcRfJ1QNgsjPvBm8f0Q5eqZM,1022
152
- dbt_adapters-1.3.2.dist-info/METADATA,sha256=-C2mKHGFDYKsM4WOK5FHnWXMhURUinnwCxRDFXTh_dY,2539
153
- dbt_adapters-1.3.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
154
- dbt_adapters-1.3.2.dist-info/licenses/LICENSE,sha256=9yjigiJhWcCZvQjdagGKDwrRph58QWc5P2bVSQwXo6s,11344
155
- dbt_adapters-1.3.2.dist-info/RECORD,,
160
+ dbt_adapters-1.4.0.dist-info/METADATA,sha256=vteZlPYemCmBasPM4IcdAuSjJwzOgc4AOBz1AkGJGGw,2547
161
+ dbt_adapters-1.4.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
162
+ dbt_adapters-1.4.0.dist-info/licenses/LICENSE,sha256=9yjigiJhWcCZvQjdagGKDwrRph58QWc5P2bVSQwXo6s,11344
163
+ dbt_adapters-1.4.0.dist-info/RECORD,,
dbt/adapters/record.py DELETED
@@ -1,67 +0,0 @@
1
- import dataclasses
2
- from io import StringIO
3
- import json
4
- import re
5
- from typing import Any, Optional, Mapping
6
-
7
- from agate import Table
8
-
9
- from dbt_common.events.contextvars import get_node_info
10
- from dbt_common.record import Record, Recorder
11
-
12
- from dbt.adapters.contracts.connection import AdapterResponse
13
-
14
-
15
- @dataclasses.dataclass
16
- class QueryRecordParams:
17
- sql: str
18
- auto_begin: bool = False
19
- fetch: bool = False
20
- limit: Optional[int] = None
21
- node_unique_id: Optional[str] = None
22
-
23
- def __post_init__(self) -> None:
24
- if self.node_unique_id is None:
25
- node_info = get_node_info()
26
- self.node_unique_id = node_info["unique_id"] if node_info else ""
27
-
28
- @staticmethod
29
- def _clean_up_sql(sql: str) -> str:
30
- sql = re.sub(r"--.*?\n", "", sql) # Remove single-line comments (--)
31
- sql = re.sub(r"/\*.*?\*/", "", sql, flags=re.DOTALL) # Remove multi-line comments (/* */)
32
- return sql.replace(" ", "").replace("\n", "")
33
-
34
- def _matches(self, other: "QueryRecordParams") -> bool:
35
- return self.node_unique_id == other.node_unique_id and self._clean_up_sql(
36
- self.sql
37
- ) == self._clean_up_sql(other.sql)
38
-
39
-
40
- @dataclasses.dataclass
41
- class QueryRecordResult:
42
- adapter_response: Optional["AdapterResponse"]
43
- table: Optional[Table]
44
-
45
- def _to_dict(self) -> Any:
46
- buf = StringIO()
47
- self.table.to_json(buf) # type: ignore
48
-
49
- return {
50
- "adapter_response": self.adapter_response.to_dict(), # type: ignore
51
- "table": buf.getvalue(),
52
- }
53
-
54
- @classmethod
55
- def _from_dict(cls, dct: Mapping) -> "QueryRecordResult":
56
- return QueryRecordResult(
57
- adapter_response=AdapterResponse.from_dict(dct["adapter_response"]),
58
- table=Table.from_object(json.loads(dct["table"])),
59
- )
60
-
61
-
62
- class QueryRecord(Record):
63
- params_cls = QueryRecordParams
64
- result_cls = QueryRecordResult
65
-
66
-
67
- Recorder.register_record_type(QueryRecord)