dbt-common 1.7.0__py3-none-any.whl → 1.9.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.
- dbt_common/__about__.py +1 -1
- dbt_common/behavior_flags.py +139 -0
- dbt_common/clients/agate_helper.py +2 -2
- dbt_common/clients/jinja.py +83 -55
- dbt_common/clients/system.py +27 -1
- dbt_common/context.py +2 -2
- dbt_common/contracts/config/base.py +95 -19
- dbt_common/contracts/util.py +10 -4
- dbt_common/dataclass_schema.py +4 -5
- dbt_common/events/contextvars.py +1 -1
- dbt_common/events/types.proto +15 -0
- dbt_common/events/types.py +20 -0
- dbt_common/events/types_pb2.py +49 -45
- dbt_common/exceptions/base.py +13 -13
- dbt_common/exceptions/jinja.py +9 -4
- dbt_common/exceptions/system.py +2 -2
- dbt_common/invocation.py +1 -1
- dbt_common/record.py +8 -2
- dbt_common/semver.py +48 -36
- dbt_common/utils/casting.py +3 -2
- dbt_common/utils/connection.py +2 -1
- dbt_common/utils/jinja.py +7 -5
- {dbt_common-1.7.0.dist-info → dbt_common-1.9.0.dist-info}/METADATA +1 -1
- {dbt_common-1.7.0.dist-info → dbt_common-1.9.0.dist-info}/RECORD +26 -25
- {dbt_common-1.7.0.dist-info → dbt_common-1.9.0.dist-info}/WHEEL +0 -0
- {dbt_common-1.7.0.dist-info → dbt_common-1.9.0.dist-info}/licenses/LICENSE +0 -0
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
4
4
|
from dataclasses import dataclass, Field
|
5
5
|
|
6
6
|
from itertools import chain
|
7
|
-
from typing import Callable, Dict,
|
7
|
+
from typing import Any, Callable, Dict, Iterator, List, Type, TypeVar
|
8
8
|
|
9
9
|
from dbt_common.contracts.config.metadata import Metadata
|
10
10
|
from dbt_common.exceptions import CompilationError, DbtInternalError
|
@@ -17,11 +17,11 @@ T = TypeVar("T", bound="BaseConfig")
|
|
17
17
|
@dataclass
|
18
18
|
class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
19
19
|
# enable syntax like: config['key']
|
20
|
-
def __getitem__(self, key):
|
20
|
+
def __getitem__(self, key: str) -> Any:
|
21
21
|
return self.get(key)
|
22
22
|
|
23
23
|
# like doing 'get' on a dictionary
|
24
|
-
def get(self, key, default=None):
|
24
|
+
def get(self, key: str, default: Any = None) -> Any:
|
25
25
|
if hasattr(self, key):
|
26
26
|
return getattr(self, key)
|
27
27
|
elif key in self._extra:
|
@@ -30,13 +30,13 @@ class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
|
30
30
|
return default
|
31
31
|
|
32
32
|
# enable syntax like: config['key'] = value
|
33
|
-
def __setitem__(self, key, value):
|
33
|
+
def __setitem__(self, key: str, value) -> None:
|
34
34
|
if hasattr(self, key):
|
35
35
|
setattr(self, key, value)
|
36
36
|
else:
|
37
37
|
self._extra[key] = value
|
38
38
|
|
39
|
-
def __delitem__(self, key):
|
39
|
+
def __delitem__(self, key: str) -> None:
|
40
40
|
if hasattr(self, key):
|
41
41
|
msg = (
|
42
42
|
'Error, tried to delete config key "{}": Cannot delete ' "built-in keys"
|
@@ -45,7 +45,7 @@ class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
|
45
45
|
else:
|
46
46
|
del self._extra[key]
|
47
47
|
|
48
|
-
def _content_iterator(self, include_condition: Callable[[Field], bool]):
|
48
|
+
def _content_iterator(self, include_condition: Callable[[Field[Any]], bool]) -> Iterator[str]:
|
49
49
|
seen = set()
|
50
50
|
for fld, _ in self._get_fields():
|
51
51
|
seen.add(fld.name)
|
@@ -57,10 +57,10 @@ class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
|
57
57
|
seen.add(key)
|
58
58
|
yield key
|
59
59
|
|
60
|
-
def __iter__(self):
|
60
|
+
def __iter__(self) -> Iterator[str]:
|
61
61
|
yield from self._content_iterator(include_condition=lambda f: True)
|
62
62
|
|
63
|
-
def __len__(self):
|
63
|
+
def __len__(self) -> int:
|
64
64
|
return len(self._get_fields()) + len(self._extra)
|
65
65
|
|
66
66
|
@staticmethod
|
@@ -76,7 +76,7 @@ class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
|
76
76
|
elif key in unrendered and key not in other:
|
77
77
|
return False
|
78
78
|
else:
|
79
|
-
return unrendered[key] == other[key]
|
79
|
+
return bool(unrendered[key] == other[key])
|
80
80
|
|
81
81
|
@classmethod
|
82
82
|
def same_contents(cls, unrendered: Dict[str, Any], other: Dict[str, Any]) -> bool:
|
@@ -96,10 +96,14 @@ class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
|
96
96
|
return False
|
97
97
|
return True
|
98
98
|
|
99
|
-
# This is used in '
|
100
|
-
# '
|
99
|
+
# This is used in 'merge_config_dicts' to create the combined orig_dict.
|
100
|
+
# Note: "clobber" fields aren't defined, because that's the default.
|
101
|
+
# "access" is currently the only Clobber field.
|
102
|
+
# This shouldn't really be defined here. It would be better to have it
|
103
|
+
# associated with the config definitions, but at the point we use it, we
|
104
|
+
# don't know which config we're dealing with.
|
101
105
|
mergebehavior = {
|
102
|
-
"append": ["pre-hook", "pre_hook", "post-hook", "post_hook", "tags"],
|
106
|
+
"append": ["pre-hook", "pre_hook", "post-hook", "post_hook", "tags", "packages"],
|
103
107
|
"update": [
|
104
108
|
"quoting",
|
105
109
|
"column_types",
|
@@ -108,6 +112,7 @@ class BaseConfig(AdditionalPropertiesAllowed, Replaceable):
|
|
108
112
|
"contract",
|
109
113
|
],
|
110
114
|
"dict_key_append": ["grants"],
|
115
|
+
"object": ["snapshot_meta_column_names"],
|
111
116
|
}
|
112
117
|
|
113
118
|
@classmethod
|
@@ -180,6 +185,7 @@ class MergeBehavior(Metadata):
|
|
180
185
|
Update = 2
|
181
186
|
Clobber = 3
|
182
187
|
DictKeyAppend = 4
|
188
|
+
Object = 5
|
183
189
|
|
184
190
|
@classmethod
|
185
191
|
def default_field(cls) -> "MergeBehavior":
|
@@ -203,11 +209,11 @@ class CompareBehavior(Metadata):
|
|
203
209
|
return "compare"
|
204
210
|
|
205
211
|
@classmethod
|
206
|
-
def should_include(cls, fld: Field) -> bool:
|
212
|
+
def should_include(cls, fld: Field[Any]) -> bool:
|
207
213
|
return cls.from_field(fld) == cls.Include
|
208
214
|
|
209
215
|
|
210
|
-
def _listify(value: Any) -> List:
|
216
|
+
def _listify(value: Any) -> List[Any]:
|
211
217
|
if isinstance(value, list):
|
212
218
|
return value[:]
|
213
219
|
else:
|
@@ -215,17 +221,20 @@ def _listify(value: Any) -> List:
|
|
215
221
|
|
216
222
|
|
217
223
|
# There are two versions of this code. The one here is for config
|
218
|
-
# objects
|
219
|
-
#
|
224
|
+
# objects which can get the "MergeBehavior" from the field in the class,
|
225
|
+
# the one below in 'merge_config_dicts' (formerly in
|
226
|
+
# _add_config_call in core context_config.py) is for config_call dictionaries
|
227
|
+
# where we need to get the MergeBehavior from someplace else.
|
220
228
|
def _merge_field_value(
|
221
229
|
merge_behavior: MergeBehavior,
|
222
230
|
self_value: Any,
|
223
231
|
other_value: Any,
|
224
|
-
):
|
232
|
+
) -> Any:
|
225
233
|
if merge_behavior == MergeBehavior.Clobber:
|
226
234
|
return other_value
|
227
235
|
elif merge_behavior == MergeBehavior.Append:
|
228
|
-
|
236
|
+
new_value = _listify(self_value) + _listify(other_value)
|
237
|
+
return new_value
|
229
238
|
elif merge_behavior == MergeBehavior.Update:
|
230
239
|
if not isinstance(self_value, dict):
|
231
240
|
raise DbtInternalError(f"expected dict, got {self_value}")
|
@@ -258,6 +267,73 @@ def _merge_field_value(
|
|
258
267
|
# clobber the list
|
259
268
|
new_dict[new_key] = _listify(other_value[key])
|
260
269
|
return new_dict
|
261
|
-
|
270
|
+
elif merge_behavior == MergeBehavior.Object:
|
271
|
+
# All fields in classes with MergeBehavior.Object should have a default of None
|
272
|
+
if not type(self_value).__name__ == type(other_value).__name__:
|
273
|
+
raise DbtInternalError(
|
274
|
+
f"got conflicting types: {type(self_value).__name__} and {type(other_value).__name__}"
|
275
|
+
)
|
276
|
+
new_value = self_value.copy()
|
277
|
+
new_value.update(other_value)
|
278
|
+
return new_value
|
262
279
|
else:
|
263
280
|
raise DbtInternalError(f"Got an invalid merge_behavior: {merge_behavior}")
|
281
|
+
|
282
|
+
|
283
|
+
# This is used in ContextConfig._add_config_call. It updates the orig_dict in place.
|
284
|
+
def merge_config_dicts(orig_dict: Dict[str, Any], new_dict: Dict[str, Any]) -> None:
|
285
|
+
# orig_dict is already encountered configs, new_dict is new
|
286
|
+
# This mirrors code in _merge_field_value in model_config.py which is similar but
|
287
|
+
# operates on config objects.
|
288
|
+
if orig_dict == {}:
|
289
|
+
orig_dict.update(new_dict)
|
290
|
+
return
|
291
|
+
for k, v in new_dict.items():
|
292
|
+
# MergeBehavior for post-hook and pre-hook is to collect all
|
293
|
+
# values, instead of overwriting
|
294
|
+
if k in BaseConfig.mergebehavior["append"]:
|
295
|
+
if k in orig_dict: # should always be a list here
|
296
|
+
orig_dict[k] = _listify(orig_dict[k]) + _listify(v)
|
297
|
+
else:
|
298
|
+
orig_dict[k] = _listify(v)
|
299
|
+
elif k in BaseConfig.mergebehavior["update"]:
|
300
|
+
if not isinstance(v, dict):
|
301
|
+
raise DbtInternalError(f"expected dict, got {v}")
|
302
|
+
if k in orig_dict and isinstance(orig_dict[k], dict):
|
303
|
+
orig_dict[k].update(v)
|
304
|
+
else:
|
305
|
+
orig_dict[k] = v
|
306
|
+
elif k in BaseConfig.mergebehavior["dict_key_append"]:
|
307
|
+
if not isinstance(v, dict):
|
308
|
+
raise DbtInternalError(f"expected dict, got {v}")
|
309
|
+
if k in orig_dict: # should always be a dict
|
310
|
+
for key in orig_dict[k].keys():
|
311
|
+
orig_dict[k][key] = _listify(orig_dict[k][key])
|
312
|
+
for key, value in v.items():
|
313
|
+
extend = False
|
314
|
+
# This might start with a +, to indicate we should extend the list
|
315
|
+
# instead of just clobbering it. We don't want to remove the + here
|
316
|
+
# (like in the other method) because we want it preserved
|
317
|
+
if key.startswith("+"):
|
318
|
+
extend = True
|
319
|
+
if key in orig_dict[k] and extend:
|
320
|
+
# extend the list
|
321
|
+
orig_dict[k][key].extend(_listify(value))
|
322
|
+
else:
|
323
|
+
# clobber the list
|
324
|
+
orig_dict[k][key] = _listify(value)
|
325
|
+
else:
|
326
|
+
# This is always a dictionary
|
327
|
+
orig_dict[k] = v
|
328
|
+
# listify everything
|
329
|
+
for key, value in orig_dict[k].items():
|
330
|
+
orig_dict[k][key] = _listify(value)
|
331
|
+
elif k in BaseConfig.mergebehavior["object"]:
|
332
|
+
if not isinstance(v, dict):
|
333
|
+
raise DbtInternalError(f"expected dict, got {v}")
|
334
|
+
if k not in orig_dict:
|
335
|
+
orig_dict[k] = {}
|
336
|
+
for obj_k, obj_v in v.items():
|
337
|
+
orig_dict[k][obj_k] = obj_v
|
338
|
+
else: # Clobber
|
339
|
+
orig_dict[k] = v
|
dbt_common/contracts/util.py
CHANGED
@@ -1,21 +1,27 @@
|
|
1
1
|
import dataclasses
|
2
|
+
from typing import Any, TypeVar
|
3
|
+
|
4
|
+
_R = TypeVar("_R", bound="Replaceable")
|
2
5
|
|
3
6
|
|
4
7
|
# TODO: remove from dbt_common.contracts.util:: Replaceable + references
|
5
8
|
class Replaceable:
|
6
|
-
def replace(self, **kwargs):
|
7
|
-
return dataclasses.replace(self, **kwargs)
|
9
|
+
def replace(self: _R, **kwargs: Any) -> _R:
|
10
|
+
return dataclasses.replace(self, **kwargs) # type: ignore
|
11
|
+
|
12
|
+
|
13
|
+
_M = TypeVar("_M", bound="Mergeable")
|
8
14
|
|
9
15
|
|
10
16
|
class Mergeable(Replaceable):
|
11
|
-
def merged(self, *args):
|
17
|
+
def merged(self: _M, *args: Any) -> _M:
|
12
18
|
"""Perform a shallow merge, where the last non-None write wins. This is
|
13
19
|
intended to merge dataclasses that are a collection of optional values.
|
14
20
|
"""
|
15
21
|
replacements = {}
|
16
22
|
cls = type(self)
|
17
23
|
for arg in args:
|
18
|
-
for field in dataclasses.fields(cls):
|
24
|
+
for field in dataclasses.fields(cls): # type: ignore
|
19
25
|
value = getattr(arg, field.name)
|
20
26
|
if value is not None:
|
21
27
|
replacements[field.name] = value
|
dbt_common/dataclass_schema.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Any,
|
1
|
+
from typing import Any, ClassVar, Dict, get_type_hints, List, Optional, Tuple, Union
|
2
2
|
import re
|
3
3
|
import jsonschema
|
4
4
|
from dataclasses import fields, Field
|
@@ -6,7 +6,6 @@ from enum import Enum
|
|
6
6
|
from datetime import datetime
|
7
7
|
from dateutil.parser import parse
|
8
8
|
|
9
|
-
# type: ignore
|
10
9
|
from mashumaro.config import (
|
11
10
|
TO_DICT_ADD_OMIT_NONE_FLAG,
|
12
11
|
ADD_SERIALIZATION_CONTEXT,
|
@@ -33,8 +32,8 @@ class DateTimeSerialization(SerializationStrategy):
|
|
33
32
|
out += "Z"
|
34
33
|
return out
|
35
34
|
|
36
|
-
def deserialize(self, value) -> datetime:
|
37
|
-
return value if isinstance(value, datetime) else parse(
|
35
|
+
def deserialize(self, value: Union[datetime, str]) -> datetime:
|
36
|
+
return value if isinstance(value, datetime) else parse(value)
|
38
37
|
|
39
38
|
|
40
39
|
class dbtMashConfig(MashBaseConfig):
|
@@ -92,7 +91,7 @@ class dbtClassMixin(DataClassMessagePackMixin):
|
|
92
91
|
return json_schema
|
93
92
|
|
94
93
|
@classmethod
|
95
|
-
def validate(cls, data):
|
94
|
+
def validate(cls, data: Any) -> None:
|
96
95
|
json_schema = cls.json_schema()
|
97
96
|
validator = jsonschema.Draft7Validator(json_schema)
|
98
97
|
error = next(iter(validator.iter_errors(data)), None)
|
dbt_common/events/contextvars.py
CHANGED
dbt_common/events/types.proto
CHANGED
@@ -23,6 +23,21 @@ message GenericMessage {
|
|
23
23
|
EventInfo info = 1;
|
24
24
|
}
|
25
25
|
|
26
|
+
// D - Deprecations
|
27
|
+
|
28
|
+
// D018
|
29
|
+
message BehaviorChangeEvent {
|
30
|
+
string flag_name = 1;
|
31
|
+
string flag_source = 2;
|
32
|
+
string description = 3;
|
33
|
+
string docs_url = 4;
|
34
|
+
}
|
35
|
+
|
36
|
+
message BehaviorChangeEventMsg {
|
37
|
+
EventInfo info = 1;
|
38
|
+
BehaviorChangeEvent data = 2;
|
39
|
+
}
|
40
|
+
|
26
41
|
// M - Deps generation
|
27
42
|
|
28
43
|
// M020
|
dbt_common/events/types.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
from dbt_common.events.base_types import (
|
2
2
|
DebugLevel,
|
3
3
|
InfoLevel,
|
4
|
+
WarnLevel,
|
4
5
|
)
|
6
|
+
from dbt_common.ui import warning_tag
|
5
7
|
|
6
8
|
|
7
9
|
# The classes in this file represent the data necessary to describe a
|
@@ -28,6 +30,24 @@ from dbt_common.events.base_types import (
|
|
28
30
|
#
|
29
31
|
# The basic idea is that event codes roughly translate to the natural order of running a dbt task
|
30
32
|
|
33
|
+
|
34
|
+
# =======================================================
|
35
|
+
# D - Deprecations
|
36
|
+
# =======================================================
|
37
|
+
|
38
|
+
|
39
|
+
class BehaviorChangeEvent(WarnLevel):
|
40
|
+
def code(self) -> str:
|
41
|
+
return "D018"
|
42
|
+
|
43
|
+
def message(self) -> str:
|
44
|
+
return warning_tag(
|
45
|
+
f"{self.description}\n"
|
46
|
+
f"You may opt into the new behavior sooner by setting `flags.{self.flag_name}` to `True` in `dbt_project.yml`.\n"
|
47
|
+
f"Visit {self.docs_url} for more information."
|
48
|
+
)
|
49
|
+
|
50
|
+
|
31
51
|
# =======================================================
|
32
52
|
# M - Deps generation
|
33
53
|
# =======================================================
|
dbt_common/events/types_pb2.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
3
|
# source: types.proto
|
4
|
-
# Protobuf Python Version:
|
4
|
+
# Protobuf Python Version: 4.25.2
|
5
5
|
"""Generated protocol buffer code."""
|
6
6
|
from google.protobuf import descriptor as _descriptor
|
7
7
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
@@ -15,14 +15,14 @@ _sym_db = _symbol_database.Default()
|
|
15
15
|
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
|
16
16
|
|
17
17
|
|
18
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0btypes.proto\x12\x0bproto_types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x91\x02\n\tEventInfo\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x63ode\x18\x02 \x01(\t\x12\x0b\n\x03msg\x18\x03 \x01(\t\x12\r\n\x05level\x18\x04 \x01(\t\x12\x15\n\rinvocation_id\x18\x05 \x01(\t\x12\x0b\n\x03pid\x18\x06 \x01(\x05\x12\x0e\n\x06thread\x18\x07 \x01(\t\x12&\n\x02ts\x18\x08 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x30\n\x05\x65xtra\x18\t \x03(\x0b\x32!.proto_types.EventInfo.ExtraEntry\x12\x10\n\x08\x63\x61tegory\x18\n \x01(\t\x1a,\n\nExtraEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"6\n\x0eGenericMessage\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\"1\n\x11RetryExternalCall\x12\x0f\n\x07\x61ttempt\x18\x01 \x01(\x05\x12\x0b\n\x03max\x18\x02 \x01(\x05\"j\n\x14RetryExternalCallMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12,\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x1e.proto_types.RetryExternalCall\"#\n\x14RecordRetryException\x12\x0b\n\x03\x65xc\x18\x01 \x01(\t\"p\n\x17RecordRetryExceptionMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12/\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32!.proto_types.RecordRetryException\"@\n\x13SystemCouldNotWrite\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x0e\n\x06reason\x18\x02 \x01(\t\x12\x0b\n\x03\x65xc\x18\x03 \x01(\t\"n\n\x16SystemCouldNotWriteMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12.\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32 .proto_types.SystemCouldNotWrite\"!\n\x12SystemExecutingCmd\x12\x0b\n\x03\x63md\x18\x01 \x03(\t\"l\n\x15SystemExecutingCmdMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12-\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x1f.proto_types.SystemExecutingCmd\"\x1c\n\x0cSystemStdOut\x12\x0c\n\x04\x62msg\x18\x01 \x01(\t\"`\n\x0fSystemStdOutMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\'\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x19.proto_types.SystemStdOut\"\x1c\n\x0cSystemStdErr\x12\x0c\n\x04\x62msg\x18\x01 \x01(\t\"`\n\x0fSystemStdErrMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\'\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x19.proto_types.SystemStdErr\",\n\x16SystemReportReturnCode\x12\x12\n\nreturncode\x18\x01 \x01(\x05\"t\n\x19SystemReportReturnCodeMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\x31\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32#.proto_types.SystemReportReturnCode\"\x19\n\nFormatting\x12\x0b\n\x03msg\x18\x01 \x01(\t\"\\\n\rFormattingMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12%\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x17.proto_types.Formatting\"\x13\n\x04Note\x12\x0b\n\x03msg\x18\x01 \x01(\t\"P\n\x07NoteMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\x1f\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x11.proto_types.Note\"\x19\n\nPrintEvent\x12\x0b\n\x03msg\x18\x01 \x01(\t\"\\\n\rPrintEventMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12%\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x17.proto_types.PrintEventb\x06proto3')
|
18
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0btypes.proto\x12\x0bproto_types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x91\x02\n\tEventInfo\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x63ode\x18\x02 \x01(\t\x12\x0b\n\x03msg\x18\x03 \x01(\t\x12\r\n\x05level\x18\x04 \x01(\t\x12\x15\n\rinvocation_id\x18\x05 \x01(\t\x12\x0b\n\x03pid\x18\x06 \x01(\x05\x12\x0e\n\x06thread\x18\x07 \x01(\t\x12&\n\x02ts\x18\x08 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x30\n\x05\x65xtra\x18\t \x03(\x0b\x32!.proto_types.EventInfo.ExtraEntry\x12\x10\n\x08\x63\x61tegory\x18\n \x01(\t\x1a,\n\nExtraEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"6\n\x0eGenericMessage\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\"d\n\x13\x42\x65haviorChangeEvent\x12\x11\n\tflag_name\x18\x01 \x01(\t\x12\x13\n\x0b\x66lag_source\x18\x02 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\x12\x10\n\x08\x64ocs_url\x18\x04 \x01(\t\"n\n\x16\x42\x65haviorChangeEventMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12.\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32 .proto_types.BehaviorChangeEvent\"1\n\x11RetryExternalCall\x12\x0f\n\x07\x61ttempt\x18\x01 \x01(\x05\x12\x0b\n\x03max\x18\x02 \x01(\x05\"j\n\x14RetryExternalCallMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12,\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x1e.proto_types.RetryExternalCall\"#\n\x14RecordRetryException\x12\x0b\n\x03\x65xc\x18\x01 \x01(\t\"p\n\x17RecordRetryExceptionMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12/\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32!.proto_types.RecordRetryException\"@\n\x13SystemCouldNotWrite\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x0e\n\x06reason\x18\x02 \x01(\t\x12\x0b\n\x03\x65xc\x18\x03 \x01(\t\"n\n\x16SystemCouldNotWriteMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12.\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32 .proto_types.SystemCouldNotWrite\"!\n\x12SystemExecutingCmd\x12\x0b\n\x03\x63md\x18\x01 \x03(\t\"l\n\x15SystemExecutingCmdMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12-\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x1f.proto_types.SystemExecutingCmd\"\x1c\n\x0cSystemStdOut\x12\x0c\n\x04\x62msg\x18\x01 \x01(\t\"`\n\x0fSystemStdOutMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\'\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x19.proto_types.SystemStdOut\"\x1c\n\x0cSystemStdErr\x12\x0c\n\x04\x62msg\x18\x01 \x01(\t\"`\n\x0fSystemStdErrMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\'\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x19.proto_types.SystemStdErr\",\n\x16SystemReportReturnCode\x12\x12\n\nreturncode\x18\x01 \x01(\x05\"t\n\x19SystemReportReturnCodeMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\x31\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32#.proto_types.SystemReportReturnCode\"\x19\n\nFormatting\x12\x0b\n\x03msg\x18\x01 \x01(\t\"\\\n\rFormattingMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12%\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x17.proto_types.Formatting\"\x13\n\x04Note\x12\x0b\n\x03msg\x18\x01 \x01(\t\"P\n\x07NoteMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12\x1f\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x11.proto_types.Note\"\x19\n\nPrintEvent\x12\x0b\n\x03msg\x18\x01 \x01(\t\"\\\n\rPrintEventMsg\x12$\n\x04info\x18\x01 \x01(\x0b\x32\x16.proto_types.EventInfo\x12%\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x17.proto_types.PrintEventb\x06proto3')
|
19
19
|
|
20
20
|
_globals = globals()
|
21
21
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
22
22
|
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'types_pb2', _globals)
|
23
|
-
if
|
24
|
-
DESCRIPTOR.
|
25
|
-
_globals['_EVENTINFO_EXTRAENTRY'].
|
23
|
+
if _descriptor._USE_C_DESCRIPTORS == False:
|
24
|
+
DESCRIPTOR._options = None
|
25
|
+
_globals['_EVENTINFO_EXTRAENTRY']._options = None
|
26
26
|
_globals['_EVENTINFO_EXTRAENTRY']._serialized_options = b'8\001'
|
27
27
|
_globals['_EVENTINFO']._serialized_start=62
|
28
28
|
_globals['_EVENTINFO']._serialized_end=335
|
@@ -30,44 +30,48 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
30
30
|
_globals['_EVENTINFO_EXTRAENTRY']._serialized_end=335
|
31
31
|
_globals['_GENERICMESSAGE']._serialized_start=337
|
32
32
|
_globals['_GENERICMESSAGE']._serialized_end=391
|
33
|
-
_globals['
|
34
|
-
_globals['
|
35
|
-
_globals['
|
36
|
-
_globals['
|
37
|
-
_globals['
|
38
|
-
_globals['
|
39
|
-
_globals['
|
40
|
-
_globals['
|
41
|
-
_globals['
|
42
|
-
_globals['
|
43
|
-
_globals['
|
44
|
-
_globals['
|
45
|
-
_globals['
|
46
|
-
_globals['
|
47
|
-
_globals['
|
48
|
-
_globals['
|
49
|
-
_globals['
|
50
|
-
_globals['
|
51
|
-
_globals['
|
52
|
-
_globals['
|
53
|
-
_globals['
|
54
|
-
_globals['
|
55
|
-
_globals['
|
56
|
-
_globals['
|
57
|
-
_globals['
|
58
|
-
_globals['
|
59
|
-
_globals['
|
60
|
-
_globals['
|
61
|
-
_globals['
|
62
|
-
_globals['
|
63
|
-
_globals['
|
64
|
-
_globals['
|
65
|
-
_globals['
|
66
|
-
_globals['
|
67
|
-
_globals['
|
68
|
-
_globals['
|
69
|
-
_globals['
|
70
|
-
_globals['
|
71
|
-
_globals['
|
72
|
-
_globals['
|
33
|
+
_globals['_BEHAVIORCHANGEEVENT']._serialized_start=393
|
34
|
+
_globals['_BEHAVIORCHANGEEVENT']._serialized_end=493
|
35
|
+
_globals['_BEHAVIORCHANGEEVENTMSG']._serialized_start=495
|
36
|
+
_globals['_BEHAVIORCHANGEEVENTMSG']._serialized_end=605
|
37
|
+
_globals['_RETRYEXTERNALCALL']._serialized_start=607
|
38
|
+
_globals['_RETRYEXTERNALCALL']._serialized_end=656
|
39
|
+
_globals['_RETRYEXTERNALCALLMSG']._serialized_start=658
|
40
|
+
_globals['_RETRYEXTERNALCALLMSG']._serialized_end=764
|
41
|
+
_globals['_RECORDRETRYEXCEPTION']._serialized_start=766
|
42
|
+
_globals['_RECORDRETRYEXCEPTION']._serialized_end=801
|
43
|
+
_globals['_RECORDRETRYEXCEPTIONMSG']._serialized_start=803
|
44
|
+
_globals['_RECORDRETRYEXCEPTIONMSG']._serialized_end=915
|
45
|
+
_globals['_SYSTEMCOULDNOTWRITE']._serialized_start=917
|
46
|
+
_globals['_SYSTEMCOULDNOTWRITE']._serialized_end=981
|
47
|
+
_globals['_SYSTEMCOULDNOTWRITEMSG']._serialized_start=983
|
48
|
+
_globals['_SYSTEMCOULDNOTWRITEMSG']._serialized_end=1093
|
49
|
+
_globals['_SYSTEMEXECUTINGCMD']._serialized_start=1095
|
50
|
+
_globals['_SYSTEMEXECUTINGCMD']._serialized_end=1128
|
51
|
+
_globals['_SYSTEMEXECUTINGCMDMSG']._serialized_start=1130
|
52
|
+
_globals['_SYSTEMEXECUTINGCMDMSG']._serialized_end=1238
|
53
|
+
_globals['_SYSTEMSTDOUT']._serialized_start=1240
|
54
|
+
_globals['_SYSTEMSTDOUT']._serialized_end=1268
|
55
|
+
_globals['_SYSTEMSTDOUTMSG']._serialized_start=1270
|
56
|
+
_globals['_SYSTEMSTDOUTMSG']._serialized_end=1366
|
57
|
+
_globals['_SYSTEMSTDERR']._serialized_start=1368
|
58
|
+
_globals['_SYSTEMSTDERR']._serialized_end=1396
|
59
|
+
_globals['_SYSTEMSTDERRMSG']._serialized_start=1398
|
60
|
+
_globals['_SYSTEMSTDERRMSG']._serialized_end=1494
|
61
|
+
_globals['_SYSTEMREPORTRETURNCODE']._serialized_start=1496
|
62
|
+
_globals['_SYSTEMREPORTRETURNCODE']._serialized_end=1540
|
63
|
+
_globals['_SYSTEMREPORTRETURNCODEMSG']._serialized_start=1542
|
64
|
+
_globals['_SYSTEMREPORTRETURNCODEMSG']._serialized_end=1658
|
65
|
+
_globals['_FORMATTING']._serialized_start=1660
|
66
|
+
_globals['_FORMATTING']._serialized_end=1685
|
67
|
+
_globals['_FORMATTINGMSG']._serialized_start=1687
|
68
|
+
_globals['_FORMATTINGMSG']._serialized_end=1779
|
69
|
+
_globals['_NOTE']._serialized_start=1781
|
70
|
+
_globals['_NOTE']._serialized_end=1800
|
71
|
+
_globals['_NOTEMSG']._serialized_start=1802
|
72
|
+
_globals['_NOTEMSG']._serialized_end=1882
|
73
|
+
_globals['_PRINTEVENT']._serialized_start=1884
|
74
|
+
_globals['_PRINTEVENT']._serialized_end=1909
|
75
|
+
_globals['_PRINTEVENTMSG']._serialized_start=1911
|
76
|
+
_globals['_PRINTEVENTMSG']._serialized_end=2003
|
73
77
|
# @@protoc_insertion_point(module_scope)
|
dbt_common/exceptions/base.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import builtins
|
2
|
-
from typing import Any, List, Optional
|
2
|
+
from typing import Any, Dict, List, Optional
|
3
3
|
import os
|
4
4
|
|
5
5
|
from dbt_common.constants import SECRET_ENV_PREFIX
|
@@ -23,7 +23,7 @@ class DbtBaseException(Exception):
|
|
23
23
|
CODE = -32000
|
24
24
|
MESSAGE = "Server Error"
|
25
25
|
|
26
|
-
def data(self):
|
26
|
+
def data(self) -> Dict[str, Any]:
|
27
27
|
# if overriding, make sure the result is json-serializable.
|
28
28
|
return {
|
29
29
|
"type": self.__class__.__name__,
|
@@ -32,7 +32,7 @@ class DbtBaseException(Exception):
|
|
32
32
|
|
33
33
|
|
34
34
|
class DbtInternalError(DbtBaseException):
|
35
|
-
def __init__(self, msg: str):
|
35
|
+
def __init__(self, msg: str) -> None:
|
36
36
|
self.stack: List = []
|
37
37
|
self.msg = scrub_secrets(msg, env_secrets())
|
38
38
|
|
@@ -40,7 +40,7 @@ class DbtInternalError(DbtBaseException):
|
|
40
40
|
def type(self) -> str:
|
41
41
|
return "Internal"
|
42
42
|
|
43
|
-
def process_stack(self):
|
43
|
+
def process_stack(self) -> List[str]:
|
44
44
|
lines = []
|
45
45
|
stack = self.stack
|
46
46
|
first = True
|
@@ -81,7 +81,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
81
81
|
self.node = node
|
82
82
|
self.msg = scrub_secrets(msg, env_secrets())
|
83
83
|
|
84
|
-
def add_node(self, node=None):
|
84
|
+
def add_node(self, node=None) -> None:
|
85
85
|
if node is not None and node is not self.node:
|
86
86
|
if self.node is not None:
|
87
87
|
self.stack.append(self.node)
|
@@ -91,7 +91,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
91
91
|
def type(self):
|
92
92
|
return "Runtime"
|
93
93
|
|
94
|
-
def node_to_string(self, node: Any):
|
94
|
+
def node_to_string(self, node: Any) -> str:
|
95
95
|
"""Given a node-like object we attempt to create the best identifier we can."""
|
96
96
|
result = ""
|
97
97
|
if hasattr(node, "resource_type"):
|
@@ -103,7 +103,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
103
103
|
|
104
104
|
return result.strip() if result != "" else "<Unknown>"
|
105
105
|
|
106
|
-
def process_stack(self):
|
106
|
+
def process_stack(self) -> List[str]:
|
107
107
|
lines = []
|
108
108
|
stack = self.stack + [self.node]
|
109
109
|
first = True
|
@@ -122,7 +122,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
122
122
|
|
123
123
|
return lines
|
124
124
|
|
125
|
-
def validator_error_message(self, exc: builtins.Exception):
|
125
|
+
def validator_error_message(self, exc: builtins.Exception) -> str:
|
126
126
|
"""Given a dbt.dataclass_schema.ValidationError return the relevant parts as a string.
|
127
127
|
|
128
128
|
dbt.dataclass_schema.ValidationError is basically a jsonschema.ValidationError)
|
@@ -132,7 +132,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
132
132
|
path = "[%s]" % "][".join(map(repr, exc.relative_path))
|
133
133
|
return f"at path {path}: {exc.message}"
|
134
134
|
|
135
|
-
def __str__(self, prefix: str = "! "):
|
135
|
+
def __str__(self, prefix: str = "! ") -> str:
|
136
136
|
node_string = ""
|
137
137
|
|
138
138
|
if self.node is not None:
|
@@ -149,7 +149,7 @@ class DbtRuntimeError(RuntimeError, DbtBaseException):
|
|
149
149
|
|
150
150
|
return lines[0] + "\n" + "\n".join([" " + line for line in lines[1:]])
|
151
151
|
|
152
|
-
def data(self):
|
152
|
+
def data(self) -> Dict[str, Any]:
|
153
153
|
result = DbtBaseException.data(self)
|
154
154
|
if self.node is None:
|
155
155
|
return result
|
@@ -236,7 +236,7 @@ class DbtDatabaseError(DbtRuntimeError):
|
|
236
236
|
CODE = 10003
|
237
237
|
MESSAGE = "Database Error"
|
238
238
|
|
239
|
-
def process_stack(self):
|
239
|
+
def process_stack(self) -> List[str]:
|
240
240
|
lines = []
|
241
241
|
|
242
242
|
if hasattr(self.node, "build_path") and self.node.build_path:
|
@@ -250,7 +250,7 @@ class DbtDatabaseError(DbtRuntimeError):
|
|
250
250
|
|
251
251
|
|
252
252
|
class UnexpectedNullError(DbtDatabaseError):
|
253
|
-
def __init__(self, field_name: str, source):
|
253
|
+
def __init__(self, field_name: str, source) -> None:
|
254
254
|
self.field_name = field_name
|
255
255
|
self.source = source
|
256
256
|
msg = (
|
@@ -268,7 +268,7 @@ class CommandError(DbtRuntimeError):
|
|
268
268
|
self.cmd = cmd_scrubbed
|
269
269
|
self.args = (cwd, cmd_scrubbed, msg)
|
270
270
|
|
271
|
-
def __str__(self):
|
271
|
+
def __str__(self, prefix: str = "! ") -> str:
|
272
272
|
if len(self.cmd) == 0:
|
273
273
|
return f"{self.msg}: No arguments given"
|
274
274
|
return f'{self.msg}: "{self.cmd[0]}"'
|
dbt_common/exceptions/jinja.py
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
from typing import TYPE_CHECKING
|
2
|
+
|
3
|
+
if TYPE_CHECKING:
|
4
|
+
from dbt_common.clients._jinja_blocks import Tag, TagIterator
|
5
|
+
|
1
6
|
from dbt_common.exceptions import CompilationError
|
2
7
|
|
3
8
|
|
4
9
|
class BlockDefinitionNotAtTopError(CompilationError):
|
5
|
-
def __init__(self, tag_parser, tag_start) -> None:
|
10
|
+
def __init__(self, tag_parser: "TagIterator", tag_start: int) -> None:
|
6
11
|
self.tag_parser = tag_parser
|
7
12
|
self.tag_start = tag_start
|
8
13
|
super().__init__(msg=self.get_message())
|
@@ -31,7 +36,7 @@ class MissingCloseTagError(CompilationError):
|
|
31
36
|
|
32
37
|
|
33
38
|
class MissingControlFlowStartTagError(CompilationError):
|
34
|
-
def __init__(self, tag, expected_tag: str, tag_parser) -> None:
|
39
|
+
def __init__(self, tag: "Tag", expected_tag: str, tag_parser: "TagIterator") -> None:
|
35
40
|
self.tag = tag
|
36
41
|
self.expected_tag = expected_tag
|
37
42
|
self.tag_parser = tag_parser
|
@@ -47,7 +52,7 @@ class MissingControlFlowStartTagError(CompilationError):
|
|
47
52
|
|
48
53
|
|
49
54
|
class NestedTagsError(CompilationError):
|
50
|
-
def __init__(self, outer, inner) -> None:
|
55
|
+
def __init__(self, outer: "Tag", inner: "Tag") -> None:
|
51
56
|
self.outer = outer
|
52
57
|
self.inner = inner
|
53
58
|
super().__init__(msg=self.get_message())
|
@@ -62,7 +67,7 @@ class NestedTagsError(CompilationError):
|
|
62
67
|
|
63
68
|
|
64
69
|
class UnexpectedControlFlowEndTagError(CompilationError):
|
65
|
-
def __init__(self, tag, expected_tag: str, tag_parser) -> None:
|
70
|
+
def __init__(self, tag: "Tag", expected_tag: str, tag_parser: "TagIterator") -> None:
|
66
71
|
self.tag = tag
|
67
72
|
self.expected_tag = expected_tag
|
68
73
|
self.tag_parser = tag_parser
|
dbt_common/exceptions/system.py
CHANGED
@@ -26,7 +26,7 @@ class WorkingDirectoryError(CommandError):
|
|
26
26
|
def __init__(self, cwd: str, cmd: List[str], msg: str) -> None:
|
27
27
|
super().__init__(cwd, cmd, msg)
|
28
28
|
|
29
|
-
def __str__(self):
|
29
|
+
def __str__(self, prefix: str = "! ") -> str:
|
30
30
|
return f'{self.msg}: "{self.cwd}"'
|
31
31
|
|
32
32
|
|
@@ -46,5 +46,5 @@ class CommandResultError(CommandError):
|
|
46
46
|
self.stderr = scrub_secrets(stderr.decode("utf-8"), env_secrets())
|
47
47
|
self.args = (cwd, self.cmd, returncode, self.stdout, self.stderr, msg)
|
48
48
|
|
49
|
-
def __str__(self):
|
49
|
+
def __str__(self, prefix: str = "! ") -> str:
|
50
50
|
return f"{self.msg} running: {self.cmd}"
|