dbt-common 1.4.0__py3-none-any.whl → 1.6.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/clients/system.py +12 -12
- dbt_common/context.py +37 -5
- dbt_common/contracts/constraints.py +2 -0
- dbt_common/dataclass_schema.py +4 -4
- dbt_common/exceptions/base.py +3 -3
- dbt_common/helper_types.py +2 -2
- dbt_common/record.py +59 -35
- dbt_common/semver.py +16 -14
- dbt_common/utils/casting.py +3 -3
- dbt_common/utils/executor.py +6 -3
- dbt_common/utils/jinja.py +5 -3
- {dbt_common-1.4.0.dist-info → dbt_common-1.6.0.dist-info}/METADATA +1 -1
- {dbt_common-1.4.0.dist-info → dbt_common-1.6.0.dist-info}/RECORD +16 -16
- {dbt_common-1.4.0.dist-info → dbt_common-1.6.0.dist-info}/WHEEL +1 -1
- {dbt_common-1.4.0.dist-info → dbt_common-1.6.0.dist-info}/licenses/LICENSE +0 -0
dbt_common/__about__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
version = "1.
|
1
|
+
version = "1.6.0"
|
dbt_common/clients/system.py
CHANGED
@@ -38,6 +38,15 @@ else:
|
|
38
38
|
c_bool = None
|
39
39
|
|
40
40
|
|
41
|
+
def _record_path(path: str) -> bool:
|
42
|
+
return (
|
43
|
+
# TODO: The first check here obviates the next two checks but is probably too coarse?
|
44
|
+
"dbt/include" not in path
|
45
|
+
and "dbt/include/global_project" not in path
|
46
|
+
and "/plugins/postgres/dbt/include/" not in path
|
47
|
+
)
|
48
|
+
|
49
|
+
|
41
50
|
@dataclasses.dataclass
|
42
51
|
class FindMatchingParams:
|
43
52
|
root_path: str
|
@@ -61,10 +70,7 @@ class FindMatchingParams:
|
|
61
70
|
def _include(self) -> bool:
|
62
71
|
# Do not record or replay filesystem searches that were performed against
|
63
72
|
# files which are actually part of dbt's implementation.
|
64
|
-
return (
|
65
|
-
"dbt/include/global_project" not in self.root_path
|
66
|
-
and "/plugins/postgres/dbt/include/" not in self.root_path
|
67
|
-
)
|
73
|
+
return _record_path(self.root_path)
|
68
74
|
|
69
75
|
|
70
76
|
@dataclasses.dataclass
|
@@ -148,10 +154,7 @@ class LoadFileParams:
|
|
148
154
|
def _include(self) -> bool:
|
149
155
|
# Do not record or replay file reads that were performed against files
|
150
156
|
# which are actually part of dbt's implementation.
|
151
|
-
return (
|
152
|
-
"dbt/include/global_project" not in self.path
|
153
|
-
and "/plugins/postgres/dbt/include/" not in self.path
|
154
|
-
)
|
157
|
+
return _record_path(self.path)
|
155
158
|
|
156
159
|
|
157
160
|
@dataclasses.dataclass
|
@@ -246,10 +249,7 @@ class WriteFileParams:
|
|
246
249
|
def _include(self) -> bool:
|
247
250
|
# Do not record or replay file reads that were performed against files
|
248
251
|
# which are actually part of dbt's implementation.
|
249
|
-
return (
|
250
|
-
"dbt/include/global_project" not in self.path
|
251
|
-
and "/plugins/postgres/dbt/include/" not in self.path
|
252
|
-
)
|
252
|
+
return _record_path(self.path)
|
253
253
|
|
254
254
|
|
255
255
|
@Recorder.register_record_type
|
dbt_common/context.py
CHANGED
@@ -1,15 +1,47 @@
|
|
1
|
+
import os
|
1
2
|
from contextvars import ContextVar, copy_context
|
2
|
-
from typing import List, Mapping, Optional
|
3
|
+
from typing import List, Mapping, Optional, Iterator
|
3
4
|
|
4
5
|
from dbt_common.constants import PRIVATE_ENV_PREFIX, SECRET_ENV_PREFIX
|
6
|
+
from dbt_common.record import Recorder
|
7
|
+
|
8
|
+
|
9
|
+
class CaseInsensitiveMapping(Mapping):
|
10
|
+
def __init__(self, env: Mapping[str, str]):
|
11
|
+
self._env = {k.casefold(): (k, v) for k, v in env.items()}
|
12
|
+
|
13
|
+
def __getitem__(self, key: str) -> str:
|
14
|
+
return self._env[key.casefold()][1]
|
15
|
+
|
16
|
+
def __len__(self) -> int:
|
17
|
+
return len(self._env)
|
18
|
+
|
19
|
+
def __iter__(self) -> Iterator[str]:
|
20
|
+
for item in self._env.items():
|
21
|
+
yield item[0]
|
5
22
|
|
6
23
|
|
7
24
|
class InvocationContext:
|
8
25
|
def __init__(self, env: Mapping[str, str]):
|
9
|
-
self._env
|
26
|
+
self._env: Mapping[str, str]
|
27
|
+
|
28
|
+
env_public = {}
|
29
|
+
env_private = {}
|
30
|
+
|
31
|
+
for k, v in env.items():
|
32
|
+
if k.startswith(PRIVATE_ENV_PREFIX):
|
33
|
+
env_private[k] = v
|
34
|
+
else:
|
35
|
+
env_public[k] = v
|
36
|
+
|
37
|
+
if os.name == "nt":
|
38
|
+
self._env = CaseInsensitiveMapping(env_public)
|
39
|
+
else:
|
40
|
+
self._env = env_public
|
41
|
+
|
10
42
|
self._env_secrets: Optional[List[str]] = None
|
11
|
-
self._env_private =
|
12
|
-
self.recorder = None
|
43
|
+
self._env_private = env_private
|
44
|
+
self.recorder: Optional[Recorder] = None
|
13
45
|
# This class will also eventually manage the invocation_id, flags, event manager, etc.
|
14
46
|
|
15
47
|
@property
|
@@ -32,7 +64,7 @@ class InvocationContext:
|
|
32
64
|
_INVOCATION_CONTEXT_VAR: ContextVar[InvocationContext] = ContextVar("DBT_INVOCATION_CONTEXT_VAR")
|
33
65
|
|
34
66
|
|
35
|
-
def reliably_get_invocation_var() -> ContextVar:
|
67
|
+
def reliably_get_invocation_var() -> ContextVar[InvocationContext]:
|
36
68
|
invocation_var: Optional[ContextVar] = next(
|
37
69
|
(cv for cv in copy_context() if cv.name == _INVOCATION_CONTEXT_VAR.name), None
|
38
70
|
)
|
@@ -36,6 +36,8 @@ class ColumnLevelConstraint(dbtClassMixin):
|
|
36
36
|
warn_unsupported: bool = (
|
37
37
|
True # Warn if constraint is not supported by the platform and won't be in DDL
|
38
38
|
)
|
39
|
+
to: Optional[str] = None
|
40
|
+
to_columns: List[str] = field(default_factory=list)
|
39
41
|
|
40
42
|
|
41
43
|
@dataclass
|
dbt_common/dataclass_schema.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Any, cast, ClassVar, Dict, get_type_hints, List, Optional, Tuple
|
2
2
|
import re
|
3
3
|
import jsonschema
|
4
4
|
from dataclasses import fields, Field
|
@@ -26,7 +26,7 @@ class ValidationError(jsonschema.ValidationError):
|
|
26
26
|
|
27
27
|
|
28
28
|
class DateTimeSerialization(SerializationStrategy):
|
29
|
-
def serialize(self, value) -> str:
|
29
|
+
def serialize(self, value: datetime) -> str:
|
30
30
|
out = value.isoformat()
|
31
31
|
# Assume UTC if timezone is missing
|
32
32
|
if value.tzinfo is None:
|
@@ -127,7 +127,7 @@ class dbtClassMixin(DataClassMessagePackMixin):
|
|
127
127
|
|
128
128
|
# copied from hologram. Used in tests
|
129
129
|
@classmethod
|
130
|
-
def _get_field_names(cls):
|
130
|
+
def _get_field_names(cls) -> List[str]:
|
131
131
|
return [element[1] for element in cls._get_fields()]
|
132
132
|
|
133
133
|
|
@@ -152,7 +152,7 @@ class ValidatedStringMixin(str, SerializableType):
|
|
152
152
|
|
153
153
|
# These classes must be in this order or it doesn't work
|
154
154
|
class StrEnum(str, SerializableType, Enum):
|
155
|
-
def __str__(self):
|
155
|
+
def __str__(self) -> str:
|
156
156
|
return self.value
|
157
157
|
|
158
158
|
# https://docs.python.org/3.6/library/enum.html#using-automatic-values
|
dbt_common/exceptions/base.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import builtins
|
2
|
-
from typing import
|
2
|
+
from typing import Any, List, Optional
|
3
3
|
import os
|
4
4
|
|
5
5
|
from dbt_common.constants import SECRET_ENV_PREFIX
|
@@ -37,7 +37,7 @@ class DbtInternalError(DbtBaseException):
|
|
37
37
|
self.msg = scrub_secrets(msg, env_secrets())
|
38
38
|
|
39
39
|
@property
|
40
|
-
def type(self):
|
40
|
+
def type(self) -> str:
|
41
41
|
return "Internal"
|
42
42
|
|
43
43
|
def process_stack(self):
|
@@ -59,7 +59,7 @@ class DbtInternalError(DbtBaseException):
|
|
59
59
|
|
60
60
|
return lines
|
61
61
|
|
62
|
-
def __str__(self):
|
62
|
+
def __str__(self) -> str:
|
63
63
|
if hasattr(self.msg, "split"):
|
64
64
|
split_msg = self.msg.split("\n")
|
65
65
|
else:
|
dbt_common/helper_types.py
CHANGED
@@ -19,7 +19,7 @@ Port = NewType("Port", int)
|
|
19
19
|
class NVEnum(StrEnum):
|
20
20
|
novalue = "novalue"
|
21
21
|
|
22
|
-
def __eq__(self, other):
|
22
|
+
def __eq__(self, other) -> bool:
|
23
23
|
return isinstance(other, NVEnum)
|
24
24
|
|
25
25
|
|
@@ -59,7 +59,7 @@ class IncludeExclude(dbtClassMixin):
|
|
59
59
|
item_name in self.include or self.include in self.INCLUDE_ALL
|
60
60
|
) and item_name not in self.exclude
|
61
61
|
|
62
|
-
def _validate_items(self, items: List[str]):
|
62
|
+
def _validate_items(self, items: List[str]) -> None:
|
63
63
|
pass
|
64
64
|
|
65
65
|
|
dbt_common/record.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
external systems during a command invocation, so that the command can be re-run
|
3
3
|
later with the recording 'replayed' to dbt.
|
4
4
|
|
5
|
-
The rationale for and architecture of this module
|
5
|
+
The rationale for and architecture of this module are described in detail in the
|
6
6
|
docs/guides/record_replay.md document in this repository.
|
7
7
|
"""
|
8
8
|
import functools
|
@@ -10,11 +10,8 @@ import dataclasses
|
|
10
10
|
import json
|
11
11
|
import os
|
12
12
|
|
13
|
-
from deepdiff import DeepDiff # type: ignore
|
14
13
|
from enum import Enum
|
15
|
-
from typing import Any, Dict, List, Mapping, Optional, Type
|
16
|
-
|
17
|
-
from dbt_common.context import get_invocation_context
|
14
|
+
from typing import Any, Callable, Dict, List, Mapping, Optional, Type
|
18
15
|
|
19
16
|
|
20
17
|
class Record:
|
@@ -23,7 +20,8 @@ class Record:
|
|
23
20
|
to the request, and the 'result' is what is returned."""
|
24
21
|
|
25
22
|
params_cls: type
|
26
|
-
result_cls: Optional[type]
|
23
|
+
result_cls: Optional[type] = None
|
24
|
+
group: Optional[str] = None
|
27
25
|
|
28
26
|
def __init__(self, params, result) -> None:
|
29
27
|
self.params = params
|
@@ -54,6 +52,11 @@ class Record:
|
|
54
52
|
|
55
53
|
class Diff:
|
56
54
|
def __init__(self, current_recording_path: str, previous_recording_path: str) -> None:
|
55
|
+
# deepdiff is expensive to import, so we only do it here when we need it
|
56
|
+
from deepdiff import DeepDiff # type: ignore
|
57
|
+
|
58
|
+
self.diff = DeepDiff
|
59
|
+
|
57
60
|
self.current_recording_path = current_recording_path
|
58
61
|
self.previous_recording_path = previous_recording_path
|
59
62
|
|
@@ -69,7 +72,7 @@ class Diff:
|
|
69
72
|
if previous[i].get("result").get("table") is not None:
|
70
73
|
previous[i]["result"]["table"] = json.loads(previous[i]["result"]["table"])
|
71
74
|
|
72
|
-
return
|
75
|
+
return self.diff(previous, current, ignore_order=True, verbose_level=2)
|
73
76
|
|
74
77
|
def diff_env_records(self, current: List, previous: List) -> Dict[str, Any]:
|
75
78
|
# The mode and filepath may change. Ignore them.
|
@@ -79,12 +82,12 @@ class Diff:
|
|
79
82
|
"root[0]['result']['env']['DBT_RECORDER_MODE']",
|
80
83
|
]
|
81
84
|
|
82
|
-
return
|
85
|
+
return self.diff(
|
83
86
|
previous, current, ignore_order=True, verbose_level=2, exclude_paths=exclude_paths
|
84
87
|
)
|
85
88
|
|
86
89
|
def diff_default(self, current: List, previous: List) -> Dict[str, Any]:
|
87
|
-
return
|
90
|
+
return self.diff(previous, current, ignore_order=True, verbose_level=2)
|
88
91
|
|
89
92
|
def calculate_diff(self) -> Dict[str, Any]:
|
90
93
|
with open(self.current_recording_path) as current_recording:
|
@@ -129,10 +132,11 @@ class Recorder:
|
|
129
132
|
previous_recording_path: Optional[str] = None,
|
130
133
|
) -> None:
|
131
134
|
self.mode = mode
|
132
|
-
self.
|
135
|
+
self.recorded_types = types
|
133
136
|
self._records_by_type: Dict[str, List[Record]] = {}
|
137
|
+
self._unprocessed_records_by_type: Dict[str, List[Dict[str, Any]]] = {}
|
134
138
|
self._replay_diffs: List["Diff"] = []
|
135
|
-
self.diff: Diff
|
139
|
+
self.diff: Optional[Diff] = None
|
136
140
|
self.previous_recording_path = previous_recording_path
|
137
141
|
self.current_recording_path = current_recording_path
|
138
142
|
|
@@ -146,7 +150,7 @@ class Recorder:
|
|
146
150
|
)
|
147
151
|
|
148
152
|
if self.mode == RecorderMode.REPLAY:
|
149
|
-
self.
|
153
|
+
self._unprocessed_records_by_type = self.load(self.previous_recording_path)
|
150
154
|
|
151
155
|
@classmethod
|
152
156
|
def register_record_type(cls, rec_type) -> Any:
|
@@ -161,7 +165,14 @@ class Recorder:
|
|
161
165
|
self._records_by_type[rec_cls_name].append(record)
|
162
166
|
|
163
167
|
def pop_matching_record(self, params: Any) -> Optional[Record]:
|
164
|
-
rec_type_name = self._record_name_by_params_name
|
168
|
+
rec_type_name = self._record_name_by_params_name.get(type(params).__name__)
|
169
|
+
|
170
|
+
if rec_type_name is None:
|
171
|
+
raise Exception(
|
172
|
+
f"A record of type {type(params).__name__} was requested, but no such type has been registered."
|
173
|
+
)
|
174
|
+
|
175
|
+
self._ensure_records_processed(rec_type_name)
|
165
176
|
records = self._records_by_type[rec_type_name]
|
166
177
|
match: Optional[Record] = None
|
167
178
|
for rec in records:
|
@@ -186,22 +197,20 @@ class Recorder:
|
|
186
197
|
return dct
|
187
198
|
|
188
199
|
@classmethod
|
189
|
-
def load(cls, file_name: str) -> Dict[str, List[
|
200
|
+
def load(cls, file_name: str) -> Dict[str, List[Dict[str, Any]]]:
|
190
201
|
with open(file_name) as file:
|
191
|
-
|
202
|
+
return json.load(file)
|
192
203
|
|
193
|
-
|
204
|
+
def _ensure_records_processed(self, record_type_name: str) -> None:
|
205
|
+
if record_type_name in self._records_by_type:
|
206
|
+
return
|
194
207
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
rec_list
|
200
|
-
|
201
|
-
rec = record_cls.from_dict(record_dct)
|
202
|
-
rec_list.append(rec) # type: ignore
|
203
|
-
records_by_type[record_type_name] = rec_list
|
204
|
-
return records_by_type
|
208
|
+
rec_list = []
|
209
|
+
record_cls = self._record_cls_by_name[record_type_name]
|
210
|
+
for record_dct in self._unprocessed_records_by_type[record_type_name]:
|
211
|
+
rec = record_cls.from_dict(record_dct)
|
212
|
+
rec_list.append(rec) # type: ignore
|
213
|
+
self._records_by_type[record_type_name] = rec_list
|
205
214
|
|
206
215
|
def expect_record(self, params: Any) -> Any:
|
207
216
|
record = self.pop_matching_record(params)
|
@@ -209,16 +218,19 @@ class Recorder:
|
|
209
218
|
if record is None:
|
210
219
|
raise Exception()
|
211
220
|
|
221
|
+
if record.result is None:
|
222
|
+
return None
|
223
|
+
|
212
224
|
result_tuple = dataclasses.astuple(record.result)
|
213
225
|
return result_tuple[0] if len(result_tuple) == 1 else result_tuple
|
214
226
|
|
215
227
|
def write_diffs(self, diff_file_name) -> None:
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
)
|
228
|
+
assert self.diff is not None
|
229
|
+
with open(diff_file_name, "w") as f:
|
230
|
+
json.dump(self.diff.calculate_diff(), f)
|
220
231
|
|
221
232
|
def print_diffs(self) -> None:
|
233
|
+
assert self.diff is not None
|
222
234
|
print(repr(self.diff.calculate_diff()))
|
223
235
|
|
224
236
|
|
@@ -273,7 +285,12 @@ def get_record_types_from_dict(fp: str) -> List:
|
|
273
285
|
return list(loaded_dct.keys())
|
274
286
|
|
275
287
|
|
276
|
-
def record_function(
|
288
|
+
def record_function(
|
289
|
+
record_type,
|
290
|
+
method: bool = False,
|
291
|
+
tuple_result: bool = False,
|
292
|
+
id_field_name: Optional[str] = None,
|
293
|
+
) -> Callable:
|
277
294
|
def record_function_inner(func_to_record):
|
278
295
|
# To avoid runtime overhead and other unpleasantness, we only apply the
|
279
296
|
# record/replay decorator if a relevant env var is set.
|
@@ -281,9 +298,11 @@ def record_function(record_type, method=False, tuple_result=False):
|
|
281
298
|
return func_to_record
|
282
299
|
|
283
300
|
@functools.wraps(func_to_record)
|
284
|
-
def record_replay_wrapper(*args, **kwargs):
|
285
|
-
recorder: Recorder = None
|
301
|
+
def record_replay_wrapper(*args, **kwargs) -> Any:
|
302
|
+
recorder: Optional[Recorder] = None
|
286
303
|
try:
|
304
|
+
from dbt_common.context import get_invocation_context
|
305
|
+
|
287
306
|
recorder = get_invocation_context().recorder
|
288
307
|
except LookupError:
|
289
308
|
pass
|
@@ -291,12 +310,17 @@ def record_function(record_type, method=False, tuple_result=False):
|
|
291
310
|
if recorder is None:
|
292
311
|
return func_to_record(*args, **kwargs)
|
293
312
|
|
294
|
-
if recorder.
|
313
|
+
if recorder.recorded_types is not None and not (
|
314
|
+
record_type.__name__ in recorder.recorded_types
|
315
|
+
or record_type.group in recorder.recorded_types
|
316
|
+
):
|
295
317
|
return func_to_record(*args, **kwargs)
|
296
318
|
|
297
319
|
# For methods, peel off the 'self' argument before calling the
|
298
320
|
# params constructor.
|
299
321
|
param_args = args[1:] if method else args
|
322
|
+
if method and id_field_name is not None:
|
323
|
+
param_args = (getattr(args[0], id_field_name),) + param_args
|
300
324
|
|
301
325
|
params = record_type.params_cls(*param_args, **kwargs)
|
302
326
|
|
@@ -313,7 +337,7 @@ def record_function(record_type, method=False, tuple_result=False):
|
|
313
337
|
r = func_to_record(*args, **kwargs)
|
314
338
|
result = (
|
315
339
|
None
|
316
|
-
if
|
340
|
+
if record_type.result_cls is None
|
317
341
|
else record_type.result_cls(*r)
|
318
342
|
if tuple_result
|
319
343
|
else record_type.result_cls(r)
|
dbt_common/semver.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from dataclasses import dataclass
|
2
2
|
import re
|
3
|
-
from typing import List
|
3
|
+
from typing import List, Iterable
|
4
4
|
|
5
5
|
import dbt_common.exceptions.base
|
6
6
|
from dbt_common.exceptions import VersionsNotCompatibleError
|
@@ -74,7 +74,7 @@ def _cmp(a, b):
|
|
74
74
|
|
75
75
|
@dataclass
|
76
76
|
class VersionSpecifier(VersionSpecification):
|
77
|
-
def to_version_string(self, skip_matcher=False):
|
77
|
+
def to_version_string(self, skip_matcher: bool = False) -> str:
|
78
78
|
prerelease = ""
|
79
79
|
build = ""
|
80
80
|
matcher = ""
|
@@ -92,7 +92,7 @@ class VersionSpecifier(VersionSpecification):
|
|
92
92
|
)
|
93
93
|
|
94
94
|
@classmethod
|
95
|
-
def from_version_string(cls, version_string):
|
95
|
+
def from_version_string(cls, version_string: str) -> "VersionSpecifier":
|
96
96
|
match = _VERSION_REGEX.match(version_string)
|
97
97
|
|
98
98
|
if not match:
|
@@ -104,7 +104,7 @@ class VersionSpecifier(VersionSpecification):
|
|
104
104
|
|
105
105
|
return cls.from_dict(matched)
|
106
106
|
|
107
|
-
def __str__(self):
|
107
|
+
def __str__(self) -> str:
|
108
108
|
return self.to_version_string()
|
109
109
|
|
110
110
|
def to_range(self) -> "VersionRange":
|
@@ -192,32 +192,32 @@ class VersionSpecifier(VersionSpecification):
|
|
192
192
|
|
193
193
|
return 0
|
194
194
|
|
195
|
-
def __lt__(self, other):
|
195
|
+
def __lt__(self, other) -> bool:
|
196
196
|
return self.compare(other) == -1
|
197
197
|
|
198
|
-
def __gt__(self, other):
|
198
|
+
def __gt__(self, other) -> bool:
|
199
199
|
return self.compare(other) == 1
|
200
200
|
|
201
|
-
def __eq___(self, other):
|
201
|
+
def __eq___(self, other) -> bool:
|
202
202
|
return self.compare(other) == 0
|
203
203
|
|
204
204
|
def __cmp___(self, other):
|
205
205
|
return self.compare(other)
|
206
206
|
|
207
207
|
@property
|
208
|
-
def is_unbounded(self):
|
208
|
+
def is_unbounded(self) -> bool:
|
209
209
|
return False
|
210
210
|
|
211
211
|
@property
|
212
|
-
def is_lower_bound(self):
|
212
|
+
def is_lower_bound(self) -> bool:
|
213
213
|
return self.matcher in [Matchers.GREATER_THAN, Matchers.GREATER_THAN_OR_EQUAL]
|
214
214
|
|
215
215
|
@property
|
216
|
-
def is_upper_bound(self):
|
216
|
+
def is_upper_bound(self) -> bool:
|
217
217
|
return self.matcher in [Matchers.LESS_THAN, Matchers.LESS_THAN_OR_EQUAL]
|
218
218
|
|
219
219
|
@property
|
220
|
-
def is_exact(self):
|
220
|
+
def is_exact(self) -> bool:
|
221
221
|
return self.matcher == Matchers.EXACT
|
222
222
|
|
223
223
|
@classmethod
|
@@ -418,7 +418,7 @@ def reduce_versions(*args):
|
|
418
418
|
return to_return
|
419
419
|
|
420
420
|
|
421
|
-
def versions_compatible(*args):
|
421
|
+
def versions_compatible(*args) -> bool:
|
422
422
|
if len(args) == 1:
|
423
423
|
return True
|
424
424
|
|
@@ -429,7 +429,7 @@ def versions_compatible(*args):
|
|
429
429
|
return False
|
430
430
|
|
431
431
|
|
432
|
-
def find_possible_versions(requested_range, available_versions):
|
432
|
+
def find_possible_versions(requested_range, available_versions: Iterable[str]):
|
433
433
|
possible_versions = []
|
434
434
|
|
435
435
|
for version_string in available_versions:
|
@@ -442,7 +442,9 @@ def find_possible_versions(requested_range, available_versions):
|
|
442
442
|
return [v.to_version_string(skip_matcher=True) for v in sorted_versions]
|
443
443
|
|
444
444
|
|
445
|
-
def resolve_to_specific_version(
|
445
|
+
def resolve_to_specific_version(
|
446
|
+
requested_range, available_versions: Iterable[str]
|
447
|
+
) -> Optional[str]:
|
446
448
|
max_version = None
|
447
449
|
max_version_string = None
|
448
450
|
|
dbt_common/utils/casting.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# This is useful for proto generated classes in particular, since
|
2
2
|
# the default for protobuf for strings is the empty string, so
|
3
3
|
# Optional[str] types don't work for generated Python classes.
|
4
|
-
from typing import Optional
|
4
|
+
from typing import Any, Dict, Optional
|
5
5
|
|
6
6
|
|
7
7
|
def cast_to_str(string: Optional[str]) -> str:
|
@@ -18,8 +18,8 @@ def cast_to_int(integer: Optional[int]) -> int:
|
|
18
18
|
return integer
|
19
19
|
|
20
20
|
|
21
|
-
def cast_dict_to_dict_of_strings(dct):
|
22
|
-
new_dct = {}
|
21
|
+
def cast_dict_to_dict_of_strings(dct: Dict[Any, Any]) -> Dict[str, str]:
|
22
|
+
new_dct: Dict[str, str] = {}
|
23
23
|
for k, v in dct.items():
|
24
24
|
new_dct[str(k)] = str(v)
|
25
25
|
return new_dct
|
dbt_common/utils/executor.py
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
import concurrent.futures
|
2
2
|
from contextlib import contextmanager
|
3
|
-
from contextvars import ContextVar
|
4
3
|
from typing import Protocol, Optional
|
5
4
|
|
6
|
-
from dbt_common.context import
|
5
|
+
from dbt_common.context import (
|
6
|
+
get_invocation_context,
|
7
|
+
reliably_get_invocation_var,
|
8
|
+
InvocationContext,
|
9
|
+
)
|
7
10
|
|
8
11
|
|
9
12
|
class ConnectingExecutor(concurrent.futures.Executor):
|
@@ -63,7 +66,7 @@ class HasThreadingConfig(Protocol):
|
|
63
66
|
threads: Optional[int]
|
64
67
|
|
65
68
|
|
66
|
-
def _thread_initializer(invocation_context:
|
69
|
+
def _thread_initializer(invocation_context: InvocationContext) -> None:
|
67
70
|
invocation_var = reliably_get_invocation_var()
|
68
71
|
invocation_var.set(invocation_context)
|
69
72
|
|
dbt_common/utils/jinja.py
CHANGED
@@ -5,19 +5,21 @@ MACRO_PREFIX = "dbt_macro__"
|
|
5
5
|
DOCS_PREFIX = "dbt_docs__"
|
6
6
|
|
7
7
|
|
8
|
-
def get_dbt_macro_name(name):
|
8
|
+
def get_dbt_macro_name(name) -> str:
|
9
9
|
if name is None:
|
10
10
|
raise DbtInternalError("Got None for a macro name!")
|
11
11
|
return f"{MACRO_PREFIX}{name}"
|
12
12
|
|
13
13
|
|
14
|
-
def get_dbt_docs_name(name):
|
14
|
+
def get_dbt_docs_name(name) -> str:
|
15
15
|
if name is None:
|
16
16
|
raise DbtInternalError("Got None for a doc name!")
|
17
17
|
return f"{DOCS_PREFIX}{name}"
|
18
18
|
|
19
19
|
|
20
|
-
def get_materialization_macro_name(
|
20
|
+
def get_materialization_macro_name(
|
21
|
+
materialization_name, adapter_type=None, with_prefix=True
|
22
|
+
) -> str:
|
21
23
|
if adapter_type is None:
|
22
24
|
adapter_type = "default"
|
23
25
|
name = f"materialization_{materialization_name}_{adapter_type}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: dbt-common
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.6.0
|
4
4
|
Summary: The shared common utilities that dbt-core and adapter implementations use
|
5
5
|
Project-URL: Homepage, https://github.com/dbt-labs/dbt-common
|
6
6
|
Project-URL: Repository, https://github.com/dbt-labs/dbt-common.git
|
@@ -1,22 +1,22 @@
|
|
1
|
-
dbt_common/__about__.py,sha256=
|
1
|
+
dbt_common/__about__.py,sha256=x8UFKPUEuSXMhqiFugvE43AvVf31jatg5kxfn9Lf_Po,18
|
2
2
|
dbt_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
dbt_common/constants.py,sha256=-Y5DIL1SDPQWtlCNizXRYxFgbx1D7LaLs1ysamvGMRk,278
|
4
|
-
dbt_common/context.py,sha256=
|
5
|
-
dbt_common/dataclass_schema.py,sha256=
|
6
|
-
dbt_common/helper_types.py,sha256=
|
4
|
+
dbt_common/context.py,sha256=mNYvTF5hWGM-x19CgOT5L35s_GcPoGIAbrzxbmz9DX4,2520
|
5
|
+
dbt_common/dataclass_schema.py,sha256=yFq1P5qkEwOJylSKe69Edirubpzgdcbvj6ThbPUH8dA,5553
|
6
|
+
dbt_common/helper_types.py,sha256=FWJGPmp7Qp2iToHyI4uvhkBbu_d1tl2_oF-obi98_N4,3917
|
7
7
|
dbt_common/invocation.py,sha256=Zw8jRPn75oi2VrUD6qGvaCDtSyIfqm5pJlPpRjs3s1E,202
|
8
8
|
dbt_common/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
-
dbt_common/record.py,sha256=
|
10
|
-
dbt_common/semver.py,sha256=
|
9
|
+
dbt_common/record.py,sha256=og-9SZhRINqW6jnqLdf3CTVKvUPdKldi52oFaa2-QRE,12658
|
10
|
+
dbt_common/semver.py,sha256=M6J5IHi04yn8R6FTwdOweD6gFFrl7KxVMc-x5WOYV9E,14130
|
11
11
|
dbt_common/tests.py,sha256=6lC_JuRtoYO6cbAF8-R5aTM4HtQiM_EH8X5m_97duGY,315
|
12
12
|
dbt_common/ui.py,sha256=rc2TEM29raBFc_LXcg901pMDD07C2ohwp9qzkE-7pBY,2567
|
13
13
|
dbt_common/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
14
|
dbt_common/clients/_jinja_blocks.py,sha256=xoJK9Y0F93U2PKfT_3SJbBopCGYCtl7LiwKuylXnrEE,12947
|
15
15
|
dbt_common/clients/agate_helper.py,sha256=n5Q0_gJPbBhFvjd286NGYGlcTtdEExYmIT3968lppyg,9124
|
16
16
|
dbt_common/clients/jinja.py,sha256=i6VQ94FU4F6ZCQLHTxNSeGHmvyYSIe34nDhNkH6wO08,18502
|
17
|
-
dbt_common/clients/system.py,sha256=
|
17
|
+
dbt_common/clients/system.py,sha256=ICFy-s-IQCbXNCmL0LTplyRvnNK8YTn7BL1_vDMffrI,22969
|
18
18
|
dbt_common/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
|
-
dbt_common/contracts/constraints.py,sha256=
|
19
|
+
dbt_common/contracts/constraints.py,sha256=_f1q3Rkcg2UwA7zI5XBbUMXnPUg6pw17UC7l1HyhyQM,1352
|
20
20
|
dbt_common/contracts/metadata.py,sha256=K_M06Rue0wmrQhFP_mq3uvQszq10CIt93oGiAVgbRfE,1293
|
21
21
|
dbt_common/contracts/util.py,sha256=RZpeEExSKdyFwTq7MM3rd1ZkAf11C7I-bgppUJ6SXOg,741
|
22
22
|
dbt_common/contracts/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -40,7 +40,7 @@ dbt_common/events/types.proto,sha256=nsOE3XFYBPovT9Th8WMkDWxBXa-adqiL23zCYfOdVk0
|
|
40
40
|
dbt_common/events/types.py,sha256=quE22Kp78J51_8f1Si_K-xg0gA2Sg-fw9XDjNrcy81M,3905
|
41
41
|
dbt_common/events/types_pb2.py,sha256=Gn3exMla0FjoA-5OQTjOeKCT_DLxzvcA3YHPfbFjAck,6563
|
42
42
|
dbt_common/exceptions/__init__.py,sha256=X_Uw7BxOzXev_9JMYfs5Cm-_i_Qf2PJim8_-dDJI7Y8,361
|
43
|
-
dbt_common/exceptions/base.py,sha256=
|
43
|
+
dbt_common/exceptions/base.py,sha256=9FVfeMn2zSZyevynwuVqKTgHBXyQ1HLZZRsubiU2FiE,7597
|
44
44
|
dbt_common/exceptions/cache.py,sha256=0z4fBcdNZMAR41YbPRo2GN0__xAMaYs8Uc-t3hjmVio,2532
|
45
45
|
dbt_common/exceptions/connection.py,sha256=rXLJXUdLhyXP3CUUyiqWN2DDO5-0Pn1ChX3OIR7pxKk,176
|
46
46
|
dbt_common/exceptions/contracts.py,sha256=i2PKRqda1Pq_Sro9FA22W7FTGklhBAGl6__nimR5_qI,527
|
@@ -49,14 +49,14 @@ dbt_common/exceptions/jinja.py,sha256=PzVUB1MFf8x81bQHTwFIGw3PyrGZzWYw04eotI4Cqt
|
|
49
49
|
dbt_common/exceptions/macros.py,sha256=2nujJrtpWHnhBwcyhcOmeVaEzILh3W9gtyP6vVpkA0o,3301
|
50
50
|
dbt_common/exceptions/system.py,sha256=w7zCilpKTiKwj0BwqVgJZy6SqiCpH61ZzvOfGnYaeoI,1549
|
51
51
|
dbt_common/utils/__init__.py,sha256=8PNb_A9zm2YfYMa0GsM-pAyJy3Iu0FUtWKvCs8kFhD0,549
|
52
|
-
dbt_common/utils/casting.py,sha256=
|
52
|
+
dbt_common/utils/casting.py,sha256=lcGLvASRRQ4q195wkQoP0BMA_AojK6Zu1yqxxjRktjo,666
|
53
53
|
dbt_common/utils/connection.py,sha256=J5zxWFpGHpUbe-F04S9bVLLO3HLvHB6INOkAey0k76c,1373
|
54
54
|
dbt_common/utils/dict.py,sha256=unI-kJs2yvw7ic2U71-6H8koVRknkb0jCk7W_FCq6_I,4014
|
55
55
|
dbt_common/utils/encoding.py,sha256=6_kSY2FvGNYMg7oX7PrbvVioieydih3Kl7Ii802LaHI,1705
|
56
|
-
dbt_common/utils/executor.py,sha256=
|
56
|
+
dbt_common/utils/executor.py,sha256=pNY0UbPlwQmTE69Vt_Rj91YGCIOEaqeYU3CjAds0T70,2454
|
57
57
|
dbt_common/utils/formatting.py,sha256=JUn5rzJ-uajs9wPCN0-f2iRFY1pOJF5YjTD9dERuLoc,165
|
58
|
-
dbt_common/utils/jinja.py,sha256=
|
59
|
-
dbt_common-1.
|
60
|
-
dbt_common-1.
|
61
|
-
dbt_common-1.
|
62
|
-
dbt_common-1.
|
58
|
+
dbt_common/utils/jinja.py,sha256=7s1-LbFBWIXZAeXMny6TpCmyd7uKrdDkCOklJ5W08qs,992
|
59
|
+
dbt_common-1.6.0.dist-info/METADATA,sha256=9yY4eknIQ9LJypjkRODINN4Jb_iZizrH5VL41EamGoI,5298
|
60
|
+
dbt_common-1.6.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
61
|
+
dbt_common-1.6.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
62
|
+
dbt_common-1.6.0.dist-info/RECORD,,
|
File without changes
|