dbt-adapters 1.22.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.
- dbt/adapters/__about__.py +1 -0
- dbt/adapters/__init__.py +8 -0
- dbt/adapters/base/README.md +13 -0
- dbt/adapters/base/__init__.py +16 -0
- dbt/adapters/base/column.py +173 -0
- dbt/adapters/base/connections.py +429 -0
- dbt/adapters/base/impl.py +2036 -0
- dbt/adapters/base/meta.py +150 -0
- dbt/adapters/base/plugin.py +32 -0
- dbt/adapters/base/query_headers.py +106 -0
- dbt/adapters/base/relation.py +648 -0
- dbt/adapters/cache.py +521 -0
- dbt/adapters/capability.py +63 -0
- dbt/adapters/catalogs/__init__.py +14 -0
- dbt/adapters/catalogs/_client.py +54 -0
- dbt/adapters/catalogs/_constants.py +1 -0
- dbt/adapters/catalogs/_exceptions.py +39 -0
- dbt/adapters/catalogs/_integration.py +113 -0
- dbt/adapters/clients/__init__.py +0 -0
- dbt/adapters/clients/jinja.py +24 -0
- dbt/adapters/contracts/__init__.py +0 -0
- dbt/adapters/contracts/connection.py +229 -0
- dbt/adapters/contracts/macros.py +11 -0
- dbt/adapters/contracts/relation.py +160 -0
- dbt/adapters/events/README.md +51 -0
- dbt/adapters/events/__init__.py +0 -0
- dbt/adapters/events/adapter_types_pb2.py +2 -0
- dbt/adapters/events/base_types.py +36 -0
- dbt/adapters/events/logging.py +83 -0
- dbt/adapters/events/types.py +436 -0
- dbt/adapters/exceptions/__init__.py +40 -0
- dbt/adapters/exceptions/alias.py +24 -0
- dbt/adapters/exceptions/cache.py +68 -0
- dbt/adapters/exceptions/compilation.py +269 -0
- dbt/adapters/exceptions/connection.py +16 -0
- dbt/adapters/exceptions/database.py +51 -0
- dbt/adapters/factory.py +264 -0
- dbt/adapters/protocol.py +150 -0
- dbt/adapters/py.typed +0 -0
- dbt/adapters/record/__init__.py +2 -0
- dbt/adapters/record/base.py +291 -0
- dbt/adapters/record/cursor/cursor.py +69 -0
- dbt/adapters/record/cursor/description.py +37 -0
- dbt/adapters/record/cursor/execute.py +39 -0
- dbt/adapters/record/cursor/fetchall.py +69 -0
- dbt/adapters/record/cursor/fetchmany.py +23 -0
- dbt/adapters/record/cursor/fetchone.py +23 -0
- dbt/adapters/record/cursor/rowcount.py +23 -0
- dbt/adapters/record/handle.py +55 -0
- dbt/adapters/record/serialization.py +115 -0
- dbt/adapters/reference_keys.py +39 -0
- dbt/adapters/relation_configs/README.md +25 -0
- dbt/adapters/relation_configs/__init__.py +12 -0
- dbt/adapters/relation_configs/config_base.py +46 -0
- dbt/adapters/relation_configs/config_change.py +26 -0
- dbt/adapters/relation_configs/config_validation.py +57 -0
- dbt/adapters/sql/__init__.py +2 -0
- dbt/adapters/sql/connections.py +263 -0
- dbt/adapters/sql/impl.py +286 -0
- dbt/adapters/utils.py +69 -0
- dbt/include/__init__.py +3 -0
- dbt/include/global_project/__init__.py +4 -0
- dbt/include/global_project/dbt_project.yml +7 -0
- dbt/include/global_project/docs/overview.md +43 -0
- dbt/include/global_project/macros/adapters/apply_grants.sql +167 -0
- dbt/include/global_project/macros/adapters/columns.sql +144 -0
- dbt/include/global_project/macros/adapters/freshness.sql +32 -0
- dbt/include/global_project/macros/adapters/indexes.sql +41 -0
- dbt/include/global_project/macros/adapters/metadata.sql +105 -0
- dbt/include/global_project/macros/adapters/persist_docs.sql +33 -0
- dbt/include/global_project/macros/adapters/relation.sql +84 -0
- dbt/include/global_project/macros/adapters/schema.sql +20 -0
- dbt/include/global_project/macros/adapters/show.sql +26 -0
- dbt/include/global_project/macros/adapters/timestamps.sql +52 -0
- dbt/include/global_project/macros/adapters/validate_sql.sql +10 -0
- dbt/include/global_project/macros/etc/datetime.sql +62 -0
- dbt/include/global_project/macros/etc/statement.sql +52 -0
- dbt/include/global_project/macros/generic_test_sql/accepted_values.sql +27 -0
- dbt/include/global_project/macros/generic_test_sql/not_null.sql +9 -0
- dbt/include/global_project/macros/generic_test_sql/relationships.sql +23 -0
- dbt/include/global_project/macros/generic_test_sql/unique.sql +12 -0
- dbt/include/global_project/macros/get_custom_name/get_custom_alias.sql +36 -0
- dbt/include/global_project/macros/get_custom_name/get_custom_database.sql +32 -0
- dbt/include/global_project/macros/get_custom_name/get_custom_schema.sql +60 -0
- dbt/include/global_project/macros/materializations/configs.sql +21 -0
- dbt/include/global_project/macros/materializations/functions/aggregate.sql +65 -0
- dbt/include/global_project/macros/materializations/functions/function.sql +20 -0
- dbt/include/global_project/macros/materializations/functions/helpers.sql +20 -0
- dbt/include/global_project/macros/materializations/functions/scalar.sql +69 -0
- dbt/include/global_project/macros/materializations/hooks.sql +35 -0
- dbt/include/global_project/macros/materializations/models/clone/can_clone_table.sql +7 -0
- dbt/include/global_project/macros/materializations/models/clone/clone.sql +67 -0
- dbt/include/global_project/macros/materializations/models/clone/create_or_replace_clone.sql +7 -0
- dbt/include/global_project/macros/materializations/models/incremental/column_helpers.sql +80 -0
- dbt/include/global_project/macros/materializations/models/incremental/incremental.sql +99 -0
- dbt/include/global_project/macros/materializations/models/incremental/is_incremental.sql +13 -0
- dbt/include/global_project/macros/materializations/models/incremental/merge.sql +120 -0
- dbt/include/global_project/macros/materializations/models/incremental/on_schema_change.sql +159 -0
- dbt/include/global_project/macros/materializations/models/incremental/strategies.sql +92 -0
- dbt/include/global_project/macros/materializations/models/materialized_view.sql +121 -0
- dbt/include/global_project/macros/materializations/models/table.sql +64 -0
- dbt/include/global_project/macros/materializations/models/view.sql +72 -0
- dbt/include/global_project/macros/materializations/seeds/helpers.sql +128 -0
- dbt/include/global_project/macros/materializations/seeds/seed.sql +60 -0
- dbt/include/global_project/macros/materializations/snapshots/helpers.sql +345 -0
- dbt/include/global_project/macros/materializations/snapshots/snapshot.sql +109 -0
- dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql +34 -0
- dbt/include/global_project/macros/materializations/snapshots/strategies.sql +184 -0
- dbt/include/global_project/macros/materializations/tests/helpers.sql +44 -0
- dbt/include/global_project/macros/materializations/tests/test.sql +66 -0
- dbt/include/global_project/macros/materializations/tests/unit.sql +40 -0
- dbt/include/global_project/macros/materializations/tests/where_subquery.sql +15 -0
- dbt/include/global_project/macros/python_model/python.sql +114 -0
- dbt/include/global_project/macros/relations/column/columns_spec_ddl.sql +89 -0
- dbt/include/global_project/macros/relations/create.sql +23 -0
- dbt/include/global_project/macros/relations/create_backup.sql +17 -0
- dbt/include/global_project/macros/relations/create_intermediate.sql +17 -0
- dbt/include/global_project/macros/relations/drop.sql +41 -0
- dbt/include/global_project/macros/relations/drop_backup.sql +14 -0
- dbt/include/global_project/macros/relations/materialized_view/alter.sql +55 -0
- dbt/include/global_project/macros/relations/materialized_view/create.sql +10 -0
- dbt/include/global_project/macros/relations/materialized_view/drop.sql +14 -0
- dbt/include/global_project/macros/relations/materialized_view/refresh.sql +9 -0
- dbt/include/global_project/macros/relations/materialized_view/rename.sql +10 -0
- dbt/include/global_project/macros/relations/materialized_view/replace.sql +10 -0
- dbt/include/global_project/macros/relations/rename.sql +35 -0
- dbt/include/global_project/macros/relations/rename_intermediate.sql +14 -0
- dbt/include/global_project/macros/relations/replace.sql +50 -0
- dbt/include/global_project/macros/relations/schema.sql +8 -0
- dbt/include/global_project/macros/relations/table/create.sql +60 -0
- dbt/include/global_project/macros/relations/table/drop.sql +14 -0
- dbt/include/global_project/macros/relations/table/rename.sql +10 -0
- dbt/include/global_project/macros/relations/table/replace.sql +10 -0
- dbt/include/global_project/macros/relations/view/create.sql +27 -0
- dbt/include/global_project/macros/relations/view/drop.sql +14 -0
- dbt/include/global_project/macros/relations/view/rename.sql +10 -0
- dbt/include/global_project/macros/relations/view/replace.sql +66 -0
- dbt/include/global_project/macros/unit_test_sql/get_fixture_sql.sql +107 -0
- dbt/include/global_project/macros/utils/any_value.sql +9 -0
- dbt/include/global_project/macros/utils/array_append.sql +8 -0
- dbt/include/global_project/macros/utils/array_concat.sql +7 -0
- dbt/include/global_project/macros/utils/array_construct.sql +12 -0
- dbt/include/global_project/macros/utils/bool_or.sql +9 -0
- dbt/include/global_project/macros/utils/cast.sql +7 -0
- dbt/include/global_project/macros/utils/cast_bool_to_text.sql +7 -0
- dbt/include/global_project/macros/utils/concat.sql +7 -0
- dbt/include/global_project/macros/utils/data_types.sql +129 -0
- dbt/include/global_project/macros/utils/date.sql +10 -0
- dbt/include/global_project/macros/utils/date_spine.sql +75 -0
- dbt/include/global_project/macros/utils/date_trunc.sql +7 -0
- dbt/include/global_project/macros/utils/dateadd.sql +14 -0
- dbt/include/global_project/macros/utils/datediff.sql +14 -0
- dbt/include/global_project/macros/utils/equals.sql +14 -0
- dbt/include/global_project/macros/utils/escape_single_quotes.sql +8 -0
- dbt/include/global_project/macros/utils/except.sql +9 -0
- dbt/include/global_project/macros/utils/generate_series.sql +53 -0
- dbt/include/global_project/macros/utils/hash.sql +7 -0
- dbt/include/global_project/macros/utils/intersect.sql +9 -0
- dbt/include/global_project/macros/utils/last_day.sql +15 -0
- dbt/include/global_project/macros/utils/length.sql +11 -0
- dbt/include/global_project/macros/utils/listagg.sql +30 -0
- dbt/include/global_project/macros/utils/literal.sql +7 -0
- dbt/include/global_project/macros/utils/position.sql +11 -0
- dbt/include/global_project/macros/utils/replace.sql +14 -0
- dbt/include/global_project/macros/utils/right.sql +12 -0
- dbt/include/global_project/macros/utils/safe_cast.sql +9 -0
- dbt/include/global_project/macros/utils/split_part.sql +26 -0
- dbt/include/global_project/tests/generic/builtin.sql +30 -0
- dbt/include/py.typed +0 -0
- dbt_adapters-1.22.2.dist-info/METADATA +124 -0
- dbt_adapters-1.22.2.dist-info/RECORD +173 -0
- dbt_adapters-1.22.2.dist-info/WHEEL +4 -0
- dbt_adapters-1.22.2.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
import traceback
|
|
3
|
+
|
|
4
|
+
from dbt_common.events import get_event_manager
|
|
5
|
+
from dbt_common.events.contextvars import get_node_info
|
|
6
|
+
from dbt_common.events.event_handler import set_package_logging
|
|
7
|
+
from dbt_common.events.functions import fire_event
|
|
8
|
+
|
|
9
|
+
from dbt.adapters.events.types import (
|
|
10
|
+
AdapterEventDebug,
|
|
11
|
+
AdapterEventError,
|
|
12
|
+
AdapterEventInfo,
|
|
13
|
+
AdapterEventWarning,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass
|
|
18
|
+
class AdapterLogger:
|
|
19
|
+
name: str
|
|
20
|
+
|
|
21
|
+
def debug(self, msg, *args) -> None:
|
|
22
|
+
event = AdapterEventDebug(
|
|
23
|
+
name=self.name,
|
|
24
|
+
base_msg=str(msg),
|
|
25
|
+
args=list(args),
|
|
26
|
+
node_info=get_node_info(),
|
|
27
|
+
)
|
|
28
|
+
fire_event(event)
|
|
29
|
+
|
|
30
|
+
def info(self, msg, *args) -> None:
|
|
31
|
+
event = AdapterEventInfo(
|
|
32
|
+
name=self.name,
|
|
33
|
+
base_msg=str(msg),
|
|
34
|
+
args=list(args),
|
|
35
|
+
node_info=get_node_info(),
|
|
36
|
+
)
|
|
37
|
+
fire_event(event)
|
|
38
|
+
|
|
39
|
+
def warning(self, msg, *args) -> None:
|
|
40
|
+
event = AdapterEventWarning(
|
|
41
|
+
name=self.name,
|
|
42
|
+
base_msg=str(msg),
|
|
43
|
+
args=list(args),
|
|
44
|
+
node_info=get_node_info(),
|
|
45
|
+
)
|
|
46
|
+
fire_event(event)
|
|
47
|
+
|
|
48
|
+
def error(self, msg, *args) -> None:
|
|
49
|
+
event = AdapterEventError(
|
|
50
|
+
name=self.name,
|
|
51
|
+
base_msg=str(msg),
|
|
52
|
+
args=list(args),
|
|
53
|
+
node_info=get_node_info(),
|
|
54
|
+
)
|
|
55
|
+
fire_event(event)
|
|
56
|
+
|
|
57
|
+
# The default exc_info=True is what makes this method different
|
|
58
|
+
def exception(self, msg, *args) -> None:
|
|
59
|
+
exc_info = str(traceback.format_exc())
|
|
60
|
+
event = AdapterEventError(
|
|
61
|
+
name=self.name,
|
|
62
|
+
base_msg=str(msg),
|
|
63
|
+
args=list(args),
|
|
64
|
+
node_info=get_node_info(),
|
|
65
|
+
exc_info=exc_info,
|
|
66
|
+
)
|
|
67
|
+
fire_event(event)
|
|
68
|
+
|
|
69
|
+
def critical(self, msg, *args) -> None:
|
|
70
|
+
event = AdapterEventError(
|
|
71
|
+
name=self.name,
|
|
72
|
+
base_msg=str(msg),
|
|
73
|
+
args=list(args),
|
|
74
|
+
node_info=get_node_info(),
|
|
75
|
+
)
|
|
76
|
+
fire_event(event)
|
|
77
|
+
|
|
78
|
+
@staticmethod
|
|
79
|
+
def set_adapter_dependency_log_level(package_name, level):
|
|
80
|
+
"""By default, dbt suppresses non-dbt package logs. This method allows
|
|
81
|
+
you to set the log level for a specific package.
|
|
82
|
+
"""
|
|
83
|
+
set_package_logging(package_name, level, get_event_manager())
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
from dbt.adapters.events.base_types import (
|
|
2
|
+
DebugLevel,
|
|
3
|
+
DynamicLevel,
|
|
4
|
+
ErrorLevel,
|
|
5
|
+
InfoLevel,
|
|
6
|
+
WarnLevel,
|
|
7
|
+
)
|
|
8
|
+
from dbt_common.ui import line_wrap_message, warning_tag
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def format_adapter_message(name, base_msg, args) -> str:
|
|
12
|
+
# only apply formatting if there are arguments to format.
|
|
13
|
+
# avoids issues like "dict: {k: v}".format() which results in `KeyError 'k'`
|
|
14
|
+
msg = base_msg if len(args) == 0 else base_msg.format(*args)
|
|
15
|
+
return f"{name} adapter: {msg}"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# =======================================================
|
|
19
|
+
# D - Deprecations
|
|
20
|
+
# =======================================================
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CollectFreshnessReturnSignature(WarnLevel):
|
|
24
|
+
def code(self) -> str:
|
|
25
|
+
return "D012"
|
|
26
|
+
|
|
27
|
+
def message(self) -> str:
|
|
28
|
+
description = (
|
|
29
|
+
"The 'collect_freshness' macro signature has changed to return the full "
|
|
30
|
+
"query result, rather than just a table of values. See the v1.5 migration guide "
|
|
31
|
+
"for details on how to update your custom macro: https://docs.getdbt.com/guides/migration/versions/upgrading-to-v1.5"
|
|
32
|
+
)
|
|
33
|
+
return line_wrap_message(warning_tag(f"Deprecated functionality\n\n{description}"))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class AdapterDeprecationWarning(WarnLevel):
|
|
37
|
+
def code(self) -> str:
|
|
38
|
+
return "D005"
|
|
39
|
+
|
|
40
|
+
def message(self) -> str:
|
|
41
|
+
description = (
|
|
42
|
+
f"The adapter function `adapter.{self.old_name}` is deprecated and will be removed in "
|
|
43
|
+
f"a future release of dbt. Please use `adapter.{self.new_name}` instead. "
|
|
44
|
+
f"\n\nDocumentation for {self.new_name} can be found here:"
|
|
45
|
+
f"\n\nhttps://docs.getdbt.com/docs/adapter"
|
|
46
|
+
)
|
|
47
|
+
return line_wrap_message(warning_tag(f"Deprecated functionality\n\n{description}"))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# =======================================================
|
|
51
|
+
# E - DB Adapter
|
|
52
|
+
# =======================================================
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class AdapterEventDebug(DebugLevel):
|
|
56
|
+
def code(self) -> str:
|
|
57
|
+
return "E001"
|
|
58
|
+
|
|
59
|
+
def message(self) -> str:
|
|
60
|
+
return format_adapter_message(self.name, self.base_msg, self.args)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class AdapterEventInfo(InfoLevel):
|
|
64
|
+
def code(self) -> str:
|
|
65
|
+
return "E002"
|
|
66
|
+
|
|
67
|
+
def message(self) -> str:
|
|
68
|
+
return format_adapter_message(self.name, self.base_msg, self.args)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class AdapterEventWarning(WarnLevel):
|
|
72
|
+
def code(self) -> str:
|
|
73
|
+
return "E003"
|
|
74
|
+
|
|
75
|
+
def message(self) -> str:
|
|
76
|
+
return format_adapter_message(self.name, self.base_msg, self.args)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class AdapterEventError(ErrorLevel):
|
|
80
|
+
def code(self) -> str:
|
|
81
|
+
return "E004"
|
|
82
|
+
|
|
83
|
+
def message(self) -> str:
|
|
84
|
+
return format_adapter_message(self.name, self.base_msg, self.args)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class NewConnection(DebugLevel):
|
|
88
|
+
def code(self) -> str:
|
|
89
|
+
return "E005"
|
|
90
|
+
|
|
91
|
+
def message(self) -> str:
|
|
92
|
+
return f"Acquiring new {self.conn_type} connection '{self.conn_name}'"
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class ConnectionReused(DebugLevel):
|
|
96
|
+
def code(self) -> str:
|
|
97
|
+
return "E006"
|
|
98
|
+
|
|
99
|
+
def message(self) -> str:
|
|
100
|
+
return f"Re-using an available connection from the pool (formerly {self.orig_conn_name}, now {self.conn_name})"
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class ConnectionLeftOpenInCleanup(DebugLevel):
|
|
104
|
+
def code(self) -> str:
|
|
105
|
+
return "E007"
|
|
106
|
+
|
|
107
|
+
def message(self) -> str:
|
|
108
|
+
return f"Connection '{self.conn_name}' was left open."
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class ConnectionClosedInCleanup(DebugLevel):
|
|
112
|
+
def code(self) -> str:
|
|
113
|
+
return "E008"
|
|
114
|
+
|
|
115
|
+
def message(self) -> str:
|
|
116
|
+
return f"Connection '{self.conn_name}' was properly closed."
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class RollbackFailed(DebugLevel):
|
|
120
|
+
def code(self) -> str:
|
|
121
|
+
return "E009"
|
|
122
|
+
|
|
123
|
+
def message(self) -> str:
|
|
124
|
+
return f"Failed to rollback '{self.conn_name}'"
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class ConnectionClosed(DebugLevel):
|
|
128
|
+
def code(self) -> str:
|
|
129
|
+
return "E010"
|
|
130
|
+
|
|
131
|
+
def message(self) -> str:
|
|
132
|
+
return f"On {self.conn_name}: Close"
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class ConnectionLeftOpen(DebugLevel):
|
|
136
|
+
def code(self) -> str:
|
|
137
|
+
return "E011"
|
|
138
|
+
|
|
139
|
+
def message(self) -> str:
|
|
140
|
+
return f"On {self.conn_name}: No close available on handle"
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class Rollback(DebugLevel):
|
|
144
|
+
def code(self) -> str:
|
|
145
|
+
return "E012"
|
|
146
|
+
|
|
147
|
+
def message(self) -> str:
|
|
148
|
+
return f"On {self.conn_name}: ROLLBACK"
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class CacheMiss(DebugLevel):
|
|
152
|
+
def code(self) -> str:
|
|
153
|
+
return "E013"
|
|
154
|
+
|
|
155
|
+
def message(self) -> str:
|
|
156
|
+
return (
|
|
157
|
+
f'On "{self.conn_name}": cache miss for schema '
|
|
158
|
+
f'"{self.database}.{self.schema}", this is inefficient'
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class ListRelations(DebugLevel):
|
|
163
|
+
def code(self) -> str:
|
|
164
|
+
return "E014"
|
|
165
|
+
|
|
166
|
+
def message(self) -> str:
|
|
167
|
+
identifiers_str = ", ".join(r.identifier for r in self.relations)
|
|
168
|
+
return f"While listing relations in database={self.database}, schema={self.schema}, found: {identifiers_str}"
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class ConnectionUsed(DebugLevel):
|
|
172
|
+
def code(self) -> str:
|
|
173
|
+
return "E015"
|
|
174
|
+
|
|
175
|
+
def message(self) -> str:
|
|
176
|
+
return f'Using {self.conn_type} connection "{self.conn_name}"'
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class SQLQuery(DebugLevel):
|
|
180
|
+
def code(self) -> str:
|
|
181
|
+
return "E016"
|
|
182
|
+
|
|
183
|
+
def message(self) -> str:
|
|
184
|
+
return f"On {self.conn_name}: {self.sql}"
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class SQLQueryStatus(DebugLevel):
|
|
188
|
+
def code(self) -> str:
|
|
189
|
+
return "E017"
|
|
190
|
+
|
|
191
|
+
def message(self) -> str:
|
|
192
|
+
return f"SQL status: {self.status} in {self.elapsed:.3f} seconds"
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class SQLCommit(DebugLevel):
|
|
196
|
+
def code(self) -> str:
|
|
197
|
+
return "E018"
|
|
198
|
+
|
|
199
|
+
def message(self) -> str:
|
|
200
|
+
return f"On {self.conn_name}: COMMIT"
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class ColTypeChange(DebugLevel):
|
|
204
|
+
def code(self) -> str:
|
|
205
|
+
return "E019"
|
|
206
|
+
|
|
207
|
+
def message(self) -> str:
|
|
208
|
+
return f"Changing col type from {self.orig_type} to {self.new_type} in table {self.table}"
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
class SchemaCreation(DebugLevel):
|
|
212
|
+
def code(self) -> str:
|
|
213
|
+
return "E020"
|
|
214
|
+
|
|
215
|
+
def message(self) -> str:
|
|
216
|
+
return f'Creating schema "{self.relation}"'
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class SchemaDrop(DebugLevel):
|
|
220
|
+
def code(self) -> str:
|
|
221
|
+
return "E021"
|
|
222
|
+
|
|
223
|
+
def message(self) -> str:
|
|
224
|
+
return f'Dropping schema "{self.relation}".'
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class CacheAction(DebugLevel):
|
|
228
|
+
def code(self) -> str:
|
|
229
|
+
return "E022"
|
|
230
|
+
|
|
231
|
+
def format_ref_key(self, ref_key) -> str:
|
|
232
|
+
return f"(database={ref_key.database}, schema={ref_key.schema}, identifier={ref_key.identifier})"
|
|
233
|
+
|
|
234
|
+
def message(self) -> str:
|
|
235
|
+
ref_key = self.format_ref_key(self.ref_key)
|
|
236
|
+
ref_key_2 = self.format_ref_key(self.ref_key_2)
|
|
237
|
+
ref_key_3 = self.format_ref_key(self.ref_key_3)
|
|
238
|
+
ref_list = []
|
|
239
|
+
for rfk in self.ref_list:
|
|
240
|
+
ref_list.append(self.format_ref_key(rfk))
|
|
241
|
+
if self.action == "add_link":
|
|
242
|
+
return f"adding link, {ref_key} references {ref_key_2}"
|
|
243
|
+
elif self.action == "add_relation":
|
|
244
|
+
return f"adding relation: {ref_key}"
|
|
245
|
+
elif self.action == "drop_missing_relation":
|
|
246
|
+
return f"dropped a nonexistent relationship: {ref_key}"
|
|
247
|
+
elif self.action == "drop_cascade":
|
|
248
|
+
return f"drop {ref_key} is cascading to {ref_list}"
|
|
249
|
+
elif self.action == "drop_relation":
|
|
250
|
+
return f"Dropping relation: {ref_key}"
|
|
251
|
+
elif self.action == "update_reference":
|
|
252
|
+
return (
|
|
253
|
+
f"updated reference from {ref_key} -> {ref_key_3} to "
|
|
254
|
+
f"{ref_key_2} -> {ref_key_3}"
|
|
255
|
+
)
|
|
256
|
+
elif self.action == "temporary_relation":
|
|
257
|
+
return f"old key {ref_key} not found in self.relations, assuming temporary"
|
|
258
|
+
elif self.action == "rename_relation":
|
|
259
|
+
return f"Renaming relation {ref_key} to {ref_key_2}"
|
|
260
|
+
elif self.action == "uncached_relation":
|
|
261
|
+
return (
|
|
262
|
+
f"{ref_key_2} references {ref_key} "
|
|
263
|
+
f"but {self.ref_key.database}.{self.ref_key.schema}"
|
|
264
|
+
"is not in the cache, skipping assumed external relation"
|
|
265
|
+
)
|
|
266
|
+
else:
|
|
267
|
+
return ref_key
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
# Skipping E023, E024, E025, E026, E027, E028, E029, E030
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
class CacheDumpGraph(DebugLevel):
|
|
274
|
+
def code(self) -> str:
|
|
275
|
+
return "E031"
|
|
276
|
+
|
|
277
|
+
def message(self) -> str:
|
|
278
|
+
return f"dump {self.before_after} {self.action} : {self.dump}"
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
# Skipping E032, E033, E034
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
class AdapterRegistered(DynamicLevel):
|
|
285
|
+
def code(self) -> str:
|
|
286
|
+
return "E034"
|
|
287
|
+
|
|
288
|
+
def message(self) -> str:
|
|
289
|
+
return f"Registered adapter: {self.adapter_name}{self.adapter_version}"
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
class AdapterImportError(InfoLevel):
|
|
293
|
+
def code(self) -> str:
|
|
294
|
+
return "E035"
|
|
295
|
+
|
|
296
|
+
def message(self) -> str:
|
|
297
|
+
return f"Error importing adapter: {self.exc}"
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
class PluginLoadError(DebugLevel):
|
|
301
|
+
def code(self) -> str:
|
|
302
|
+
return "E036"
|
|
303
|
+
|
|
304
|
+
def message(self) -> str:
|
|
305
|
+
return f"{self.exc_info}"
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
class NewConnectionOpening(DebugLevel):
|
|
309
|
+
def code(self) -> str:
|
|
310
|
+
return "E037"
|
|
311
|
+
|
|
312
|
+
def message(self) -> str:
|
|
313
|
+
return f"Opening a new connection, currently in state {self.connection_state}"
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
class CodeExecution(DebugLevel):
|
|
317
|
+
def code(self) -> str:
|
|
318
|
+
return "E038"
|
|
319
|
+
|
|
320
|
+
def message(self) -> str:
|
|
321
|
+
return f"On {self.conn_name}: {self.code_content}"
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
class CodeExecutionStatus(DebugLevel):
|
|
325
|
+
def code(self) -> str:
|
|
326
|
+
return "E039"
|
|
327
|
+
|
|
328
|
+
def message(self) -> str:
|
|
329
|
+
return f"Execution status: {self.status} in {self.elapsed} seconds"
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
class CatalogGenerationError(WarnLevel):
|
|
333
|
+
def code(self) -> str:
|
|
334
|
+
return "E040"
|
|
335
|
+
|
|
336
|
+
def message(self) -> str:
|
|
337
|
+
return f"Encountered an error while generating catalog: {self.exc}"
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
class WriteCatalogFailure(ErrorLevel):
|
|
341
|
+
def code(self) -> str:
|
|
342
|
+
return "E041"
|
|
343
|
+
|
|
344
|
+
def message(self) -> str:
|
|
345
|
+
return (
|
|
346
|
+
f"dbt encountered {self.num_exceptions} failure{(self.num_exceptions != 1) * 's'} "
|
|
347
|
+
"while writing the catalog"
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
class CatalogWritten(InfoLevel):
|
|
352
|
+
def code(self) -> str:
|
|
353
|
+
return "E042"
|
|
354
|
+
|
|
355
|
+
def message(self) -> str:
|
|
356
|
+
return f"Catalog written to {self.path}"
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
class CannotGenerateDocs(InfoLevel):
|
|
360
|
+
def code(self) -> str:
|
|
361
|
+
return "E043"
|
|
362
|
+
|
|
363
|
+
def message(self) -> str:
|
|
364
|
+
return "compile failed, cannot generate docs"
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
class BuildingCatalog(InfoLevel):
|
|
368
|
+
def code(self) -> str:
|
|
369
|
+
return "E044"
|
|
370
|
+
|
|
371
|
+
def message(self) -> str:
|
|
372
|
+
return "Building catalog"
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
class DatabaseErrorRunningHook(InfoLevel):
|
|
376
|
+
def code(self) -> str:
|
|
377
|
+
return "E045"
|
|
378
|
+
|
|
379
|
+
def message(self) -> str:
|
|
380
|
+
return f"Database error while running {self.hook_type}"
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
class HooksRunning(InfoLevel):
|
|
384
|
+
def code(self) -> str:
|
|
385
|
+
return "E046"
|
|
386
|
+
|
|
387
|
+
def message(self) -> str:
|
|
388
|
+
plural = "hook" if self.num_hooks == 1 else "hooks"
|
|
389
|
+
return f"Running {self.num_hooks} {self.hook_type} {plural}"
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
class FinishedRunningStats(InfoLevel):
|
|
393
|
+
def code(self) -> str:
|
|
394
|
+
return "E047"
|
|
395
|
+
|
|
396
|
+
def message(self) -> str:
|
|
397
|
+
return f"Finished running {self.stat_line}{self.execution} ({self.execution_time:0.2f}s)."
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
class ConstraintNotEnforced(WarnLevel):
|
|
401
|
+
def code(self) -> str:
|
|
402
|
+
return "E048"
|
|
403
|
+
|
|
404
|
+
def message(self) -> str:
|
|
405
|
+
msg = (
|
|
406
|
+
f"The constraint type {self.constraint} is not enforced by {self.adapter}. "
|
|
407
|
+
"The constraint will be included in this model's DDL statement, but it will not "
|
|
408
|
+
"guarantee anything about the underlying data. Set 'warn_unenforced: false' on "
|
|
409
|
+
"this constraint to ignore this warning."
|
|
410
|
+
)
|
|
411
|
+
return line_wrap_message(warning_tag(msg))
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
class ConstraintNotSupported(WarnLevel):
|
|
415
|
+
def code(self) -> str:
|
|
416
|
+
return "E049"
|
|
417
|
+
|
|
418
|
+
def message(self) -> str:
|
|
419
|
+
msg = (
|
|
420
|
+
f"The constraint type {self.constraint} is not supported by {self.adapter}, and will "
|
|
421
|
+
"be ignored. Set 'warn_unsupported: false' on this constraint to ignore this warning."
|
|
422
|
+
)
|
|
423
|
+
return line_wrap_message(warning_tag(msg))
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
class TypeCodeNotFound(DebugLevel):
|
|
427
|
+
def code(self) -> str:
|
|
428
|
+
return "E050"
|
|
429
|
+
|
|
430
|
+
def message(self) -> str:
|
|
431
|
+
msg = (
|
|
432
|
+
f"The `type_code` {self.type_code} was not recognized, which may affect error "
|
|
433
|
+
"messages for enforced contracts that fail as well as `Column.data_type` values "
|
|
434
|
+
"returned by `get_column_schema_from_query`"
|
|
435
|
+
)
|
|
436
|
+
return line_wrap_message(warning_tag(msg))
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from dbt.adapters.exceptions.alias import AliasError, DuplicateAliasError
|
|
2
|
+
from dbt.adapters.exceptions.cache import (
|
|
3
|
+
CacheInconsistencyError,
|
|
4
|
+
DependentLinkNotCachedError,
|
|
5
|
+
NewNameAlreadyInCacheError,
|
|
6
|
+
NoneRelationFoundError,
|
|
7
|
+
ReferencedLinkNotCachedError,
|
|
8
|
+
TruncatedModelNameCausedCollisionError,
|
|
9
|
+
)
|
|
10
|
+
from dbt.adapters.exceptions.compilation import (
|
|
11
|
+
ApproximateMatchError,
|
|
12
|
+
ColumnTypeMissingError,
|
|
13
|
+
DuplicateMacroInPackageError,
|
|
14
|
+
DuplicateMaterializationNameError,
|
|
15
|
+
MacroNotFoundError,
|
|
16
|
+
MaterializationNotAvailableError,
|
|
17
|
+
MissingConfigError,
|
|
18
|
+
MissingMaterializationError,
|
|
19
|
+
MultipleDatabasesNotAllowedError,
|
|
20
|
+
NullRelationCacheAttemptedError,
|
|
21
|
+
NullRelationDropAttemptedError,
|
|
22
|
+
QuoteConfigTypeError,
|
|
23
|
+
RelationReturnedMultipleResultsError,
|
|
24
|
+
RelationTypeNullError,
|
|
25
|
+
RelationWrongTypeError,
|
|
26
|
+
RenameToNoneAttemptedError,
|
|
27
|
+
SnapshotTargetIncompleteError,
|
|
28
|
+
SnapshotTargetNotSnapshotTableError,
|
|
29
|
+
UnexpectedNonTimestampError,
|
|
30
|
+
)
|
|
31
|
+
from dbt.adapters.exceptions.connection import (
|
|
32
|
+
FailedToConnectError,
|
|
33
|
+
InvalidConnectionError,
|
|
34
|
+
)
|
|
35
|
+
from dbt.adapters.exceptions.database import (
|
|
36
|
+
CrossDbReferenceProhibitedError,
|
|
37
|
+
IndexConfigError,
|
|
38
|
+
IndexConfigNotDictError,
|
|
39
|
+
UnexpectedDbReferenceError,
|
|
40
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from typing import Any, Mapping
|
|
2
|
+
|
|
3
|
+
from dbt_common.exceptions import DbtValidationError
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AliasError(DbtValidationError):
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# core level exceptions
|
|
11
|
+
class DuplicateAliasError(AliasError):
|
|
12
|
+
def __init__(self, kwargs: Mapping[str, Any], aliases: Mapping[str, str], canonical_key: str):
|
|
13
|
+
self.kwargs = kwargs
|
|
14
|
+
self.aliases = aliases
|
|
15
|
+
self.canonical_key = canonical_key
|
|
16
|
+
super().__init__(msg=self.get_message())
|
|
17
|
+
|
|
18
|
+
def get_message(self) -> str:
|
|
19
|
+
# dupe found: go through the dict so we can have a nice-ish error
|
|
20
|
+
key_names = ", ".join(
|
|
21
|
+
"{}".format(k) for k in self.kwargs if self.aliases.get(k) == self.canonical_key
|
|
22
|
+
)
|
|
23
|
+
msg = f'Got duplicate keys: ({key_names}) all map to "{self.canonical_key}"'
|
|
24
|
+
return msg
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from typing import Dict
|
|
3
|
+
|
|
4
|
+
from dbt_common.exceptions import DbtInternalError
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CacheInconsistencyError(DbtInternalError):
|
|
8
|
+
def __init__(self, msg: str):
|
|
9
|
+
self.msg = msg
|
|
10
|
+
formatted_msg = f"Cache inconsistency detected: {self.msg}"
|
|
11
|
+
super().__init__(msg=formatted_msg)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class NewNameAlreadyInCacheError(CacheInconsistencyError):
|
|
15
|
+
def __init__(self, old_key: str, new_key: str):
|
|
16
|
+
self.old_key = old_key
|
|
17
|
+
self.new_key = new_key
|
|
18
|
+
msg = (
|
|
19
|
+
f'in rename of "{self.old_key}" -> "{self.new_key}", new name is in the cache already'
|
|
20
|
+
)
|
|
21
|
+
super().__init__(msg)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ReferencedLinkNotCachedError(CacheInconsistencyError):
|
|
25
|
+
def __init__(self, referenced_key: str):
|
|
26
|
+
self.referenced_key = referenced_key
|
|
27
|
+
msg = f"in add_link, referenced link key {self.referenced_key} not in cache!"
|
|
28
|
+
super().__init__(msg)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class DependentLinkNotCachedError(CacheInconsistencyError):
|
|
32
|
+
def __init__(self, dependent_key: str):
|
|
33
|
+
self.dependent_key = dependent_key
|
|
34
|
+
msg = f"in add_link, dependent link key {self.dependent_key} not in cache!"
|
|
35
|
+
super().__init__(msg)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class TruncatedModelNameCausedCollisionError(CacheInconsistencyError):
|
|
39
|
+
def __init__(self, new_key, relations: Dict):
|
|
40
|
+
self.new_key = new_key
|
|
41
|
+
self.relations = relations
|
|
42
|
+
super().__init__(self.get_message())
|
|
43
|
+
|
|
44
|
+
def get_message(self) -> str:
|
|
45
|
+
# Tell user when collision caused by model names truncated during
|
|
46
|
+
# materialization.
|
|
47
|
+
match = re.search("__dbt_backup|__dbt_tmp$", self.new_key.identifier)
|
|
48
|
+
if match:
|
|
49
|
+
truncated_model_name_prefix = self.new_key.identifier[: match.start()]
|
|
50
|
+
message_addendum = (
|
|
51
|
+
"\n\nName collisions can occur when the length of two "
|
|
52
|
+
"models' names approach your database's builtin limit. "
|
|
53
|
+
"Try restructuring your project such that no two models "
|
|
54
|
+
f"share the prefix '{truncated_model_name_prefix}'. "
|
|
55
|
+
"Then, clean your warehouse of any removed models."
|
|
56
|
+
)
|
|
57
|
+
else:
|
|
58
|
+
message_addendum = ""
|
|
59
|
+
|
|
60
|
+
msg = f"in rename, new key {self.new_key} already in cache: {list(self.relations.keys())}{message_addendum}"
|
|
61
|
+
|
|
62
|
+
return msg
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class NoneRelationFoundError(CacheInconsistencyError):
|
|
66
|
+
def __init__(self):
|
|
67
|
+
msg = "in get_relations, a None relation was found in the cache!"
|
|
68
|
+
super().__init__(msg)
|