dvt-core 0.52.2__cp310-cp310-macosx_10_9_x86_64.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/__init__.py +7 -0
- dbt/_pydantic_shim.py +26 -0
- dbt/artifacts/__init__.py +0 -0
- dbt/artifacts/exceptions/__init__.py +1 -0
- dbt/artifacts/exceptions/schemas.py +31 -0
- dbt/artifacts/resources/__init__.py +116 -0
- dbt/artifacts/resources/base.py +67 -0
- dbt/artifacts/resources/types.py +93 -0
- dbt/artifacts/resources/v1/analysis.py +10 -0
- dbt/artifacts/resources/v1/catalog.py +23 -0
- dbt/artifacts/resources/v1/components.py +274 -0
- dbt/artifacts/resources/v1/config.py +277 -0
- dbt/artifacts/resources/v1/documentation.py +11 -0
- dbt/artifacts/resources/v1/exposure.py +51 -0
- dbt/artifacts/resources/v1/function.py +52 -0
- dbt/artifacts/resources/v1/generic_test.py +31 -0
- dbt/artifacts/resources/v1/group.py +21 -0
- dbt/artifacts/resources/v1/hook.py +11 -0
- dbt/artifacts/resources/v1/macro.py +29 -0
- dbt/artifacts/resources/v1/metric.py +172 -0
- dbt/artifacts/resources/v1/model.py +145 -0
- dbt/artifacts/resources/v1/owner.py +10 -0
- dbt/artifacts/resources/v1/saved_query.py +111 -0
- dbt/artifacts/resources/v1/seed.py +41 -0
- dbt/artifacts/resources/v1/semantic_layer_components.py +72 -0
- dbt/artifacts/resources/v1/semantic_model.py +314 -0
- dbt/artifacts/resources/v1/singular_test.py +14 -0
- dbt/artifacts/resources/v1/snapshot.py +91 -0
- dbt/artifacts/resources/v1/source_definition.py +84 -0
- dbt/artifacts/resources/v1/sql_operation.py +10 -0
- dbt/artifacts/resources/v1/unit_test_definition.py +77 -0
- dbt/artifacts/schemas/__init__.py +0 -0
- dbt/artifacts/schemas/base.py +191 -0
- dbt/artifacts/schemas/batch_results.py +24 -0
- dbt/artifacts/schemas/catalog/__init__.py +11 -0
- dbt/artifacts/schemas/catalog/v1/__init__.py +0 -0
- dbt/artifacts/schemas/catalog/v1/catalog.py +59 -0
- dbt/artifacts/schemas/freshness/__init__.py +1 -0
- dbt/artifacts/schemas/freshness/v3/__init__.py +0 -0
- dbt/artifacts/schemas/freshness/v3/freshness.py +158 -0
- dbt/artifacts/schemas/manifest/__init__.py +2 -0
- dbt/artifacts/schemas/manifest/v12/__init__.py +0 -0
- dbt/artifacts/schemas/manifest/v12/manifest.py +211 -0
- dbt/artifacts/schemas/results.py +147 -0
- dbt/artifacts/schemas/run/__init__.py +2 -0
- dbt/artifacts/schemas/run/v5/__init__.py +0 -0
- dbt/artifacts/schemas/run/v5/run.py +184 -0
- dbt/artifacts/schemas/upgrades/__init__.py +4 -0
- dbt/artifacts/schemas/upgrades/upgrade_manifest.py +174 -0
- dbt/artifacts/schemas/upgrades/upgrade_manifest_dbt_version.py +2 -0
- dbt/artifacts/utils/validation.py +153 -0
- dbt/cli/__init__.py +1 -0
- dbt/cli/context.py +17 -0
- dbt/cli/exceptions.py +57 -0
- dbt/cli/flags.py +560 -0
- dbt/cli/main.py +2039 -0
- dbt/cli/option_types.py +121 -0
- dbt/cli/options.py +80 -0
- dbt/cli/params.py +804 -0
- dbt/cli/requires.py +490 -0
- dbt/cli/resolvers.py +50 -0
- dbt/cli/types.py +40 -0
- dbt/clients/__init__.py +0 -0
- dbt/clients/checked_load.py +83 -0
- dbt/clients/git.py +164 -0
- dbt/clients/jinja.py +206 -0
- dbt/clients/jinja_static.py +245 -0
- dbt/clients/registry.py +192 -0
- dbt/clients/yaml_helper.py +68 -0
- dbt/compilation.py +876 -0
- dbt/compute/__init__.py +14 -0
- dbt/compute/engines/__init__.py +12 -0
- dbt/compute/engines/spark_engine.py +624 -0
- dbt/compute/federated_executor.py +837 -0
- dbt/compute/filter_pushdown.cpython-310-darwin.so +0 -0
- dbt/compute/filter_pushdown.py +273 -0
- dbt/compute/jar_provisioning.cpython-310-darwin.so +0 -0
- dbt/compute/jar_provisioning.py +255 -0
- dbt/compute/java_compat.cpython-310-darwin.so +0 -0
- dbt/compute/java_compat.py +689 -0
- dbt/compute/jdbc_utils.cpython-310-darwin.so +0 -0
- dbt/compute/jdbc_utils.py +678 -0
- dbt/compute/smart_selector.cpython-310-darwin.so +0 -0
- dbt/compute/smart_selector.py +311 -0
- dbt/compute/strategies/__init__.py +54 -0
- dbt/compute/strategies/base.py +165 -0
- dbt/compute/strategies/dataproc.py +207 -0
- dbt/compute/strategies/emr.py +203 -0
- dbt/compute/strategies/local.py +364 -0
- dbt/compute/strategies/standalone.py +262 -0
- dbt/config/__init__.py +4 -0
- dbt/config/catalogs.py +94 -0
- dbt/config/compute.cpython-310-darwin.so +0 -0
- dbt/config/compute.py +547 -0
- dbt/config/dvt_profile.cpython-310-darwin.so +0 -0
- dbt/config/dvt_profile.py +342 -0
- dbt/config/profile.py +422 -0
- dbt/config/project.py +873 -0
- dbt/config/project_utils.py +28 -0
- dbt/config/renderer.py +231 -0
- dbt/config/runtime.py +553 -0
- dbt/config/selectors.py +208 -0
- dbt/config/utils.py +77 -0
- dbt/constants.py +28 -0
- dbt/context/__init__.py +0 -0
- dbt/context/base.py +745 -0
- dbt/context/configured.py +135 -0
- dbt/context/context_config.py +382 -0
- dbt/context/docs.py +82 -0
- dbt/context/exceptions_jinja.py +178 -0
- dbt/context/macro_resolver.py +195 -0
- dbt/context/macros.py +171 -0
- dbt/context/manifest.py +72 -0
- dbt/context/providers.py +2249 -0
- dbt/context/query_header.py +13 -0
- dbt/context/secret.py +58 -0
- dbt/context/target.py +74 -0
- dbt/contracts/__init__.py +0 -0
- dbt/contracts/files.py +413 -0
- dbt/contracts/graph/__init__.py +0 -0
- dbt/contracts/graph/manifest.py +1904 -0
- dbt/contracts/graph/metrics.py +97 -0
- dbt/contracts/graph/model_config.py +70 -0
- dbt/contracts/graph/node_args.py +42 -0
- dbt/contracts/graph/nodes.py +1806 -0
- dbt/contracts/graph/semantic_manifest.py +232 -0
- dbt/contracts/graph/unparsed.py +811 -0
- dbt/contracts/project.py +417 -0
- dbt/contracts/results.py +53 -0
- dbt/contracts/selection.py +23 -0
- dbt/contracts/sql.py +85 -0
- dbt/contracts/state.py +68 -0
- dbt/contracts/util.py +46 -0
- dbt/deprecations.py +346 -0
- dbt/deps/__init__.py +0 -0
- dbt/deps/base.py +152 -0
- dbt/deps/git.py +195 -0
- dbt/deps/local.py +79 -0
- dbt/deps/registry.py +130 -0
- dbt/deps/resolver.py +149 -0
- dbt/deps/tarball.py +120 -0
- dbt/docs/source/_ext/dbt_click.py +119 -0
- dbt/docs/source/conf.py +32 -0
- dbt/env_vars.py +64 -0
- dbt/event_time/event_time.py +40 -0
- dbt/event_time/sample_window.py +60 -0
- dbt/events/__init__.py +15 -0
- dbt/events/base_types.py +36 -0
- dbt/events/core_types_pb2.py +2 -0
- dbt/events/logging.py +108 -0
- dbt/events/types.py +2516 -0
- dbt/exceptions.py +1486 -0
- dbt/flags.py +89 -0
- dbt/graph/__init__.py +11 -0
- dbt/graph/cli.py +247 -0
- dbt/graph/graph.py +172 -0
- dbt/graph/queue.py +214 -0
- dbt/graph/selector.py +374 -0
- dbt/graph/selector_methods.py +975 -0
- dbt/graph/selector_spec.py +222 -0
- dbt/graph/thread_pool.py +18 -0
- dbt/hooks.py +21 -0
- dbt/include/README.md +49 -0
- dbt/include/__init__.py +3 -0
- dbt/include/starter_project/.gitignore +4 -0
- dbt/include/starter_project/README.md +15 -0
- dbt/include/starter_project/__init__.py +3 -0
- dbt/include/starter_project/analyses/.gitkeep +0 -0
- dbt/include/starter_project/dbt_project.yml +36 -0
- dbt/include/starter_project/macros/.gitkeep +0 -0
- dbt/include/starter_project/models/example/my_first_dbt_model.sql +27 -0
- dbt/include/starter_project/models/example/my_second_dbt_model.sql +6 -0
- dbt/include/starter_project/models/example/schema.yml +21 -0
- dbt/include/starter_project/seeds/.gitkeep +0 -0
- dbt/include/starter_project/snapshots/.gitkeep +0 -0
- dbt/include/starter_project/tests/.gitkeep +0 -0
- dbt/internal_deprecations.py +26 -0
- dbt/jsonschemas/__init__.py +3 -0
- dbt/jsonschemas/jsonschemas.py +309 -0
- dbt/jsonschemas/project/0.0.110.json +4717 -0
- dbt/jsonschemas/project/0.0.85.json +2015 -0
- dbt/jsonschemas/resources/0.0.110.json +2636 -0
- dbt/jsonschemas/resources/0.0.85.json +2536 -0
- dbt/jsonschemas/resources/latest.json +6773 -0
- dbt/links.py +4 -0
- dbt/materializations/__init__.py +0 -0
- dbt/materializations/incremental/__init__.py +0 -0
- dbt/materializations/incremental/microbatch.py +236 -0
- dbt/mp_context.py +8 -0
- dbt/node_types.py +37 -0
- dbt/parser/__init__.py +23 -0
- dbt/parser/analysis.py +21 -0
- dbt/parser/base.py +548 -0
- dbt/parser/common.py +266 -0
- dbt/parser/docs.py +52 -0
- dbt/parser/fixtures.py +51 -0
- dbt/parser/functions.py +30 -0
- dbt/parser/generic_test.py +100 -0
- dbt/parser/generic_test_builders.py +333 -0
- dbt/parser/hooks.py +118 -0
- dbt/parser/macros.py +137 -0
- dbt/parser/manifest.py +2204 -0
- dbt/parser/models.py +573 -0
- dbt/parser/partial.py +1178 -0
- dbt/parser/read_files.py +445 -0
- dbt/parser/schema_generic_tests.py +422 -0
- dbt/parser/schema_renderer.py +111 -0
- dbt/parser/schema_yaml_readers.py +935 -0
- dbt/parser/schemas.py +1466 -0
- dbt/parser/search.py +149 -0
- dbt/parser/seeds.py +28 -0
- dbt/parser/singular_test.py +20 -0
- dbt/parser/snapshots.py +44 -0
- dbt/parser/sources.py +558 -0
- dbt/parser/sql.py +62 -0
- dbt/parser/unit_tests.py +621 -0
- dbt/plugins/__init__.py +20 -0
- dbt/plugins/contracts.py +9 -0
- dbt/plugins/exceptions.py +2 -0
- dbt/plugins/manager.py +163 -0
- dbt/plugins/manifest.py +21 -0
- dbt/profiler.py +20 -0
- dbt/py.typed +1 -0
- dbt/query_analyzer.cpython-310-darwin.so +0 -0
- dbt/query_analyzer.py +410 -0
- dbt/runners/__init__.py +2 -0
- dbt/runners/exposure_runner.py +7 -0
- dbt/runners/no_op_runner.py +45 -0
- dbt/runners/saved_query_runner.py +7 -0
- dbt/selected_resources.py +8 -0
- dbt/task/__init__.py +0 -0
- dbt/task/base.py +503 -0
- dbt/task/build.py +197 -0
- dbt/task/clean.py +56 -0
- dbt/task/clone.py +161 -0
- dbt/task/compile.py +150 -0
- dbt/task/compute.py +454 -0
- dbt/task/debug.py +505 -0
- dbt/task/deps.py +280 -0
- dbt/task/docs/__init__.py +3 -0
- dbt/task/docs/generate.py +660 -0
- dbt/task/docs/index.html +250 -0
- dbt/task/docs/serve.py +29 -0
- dbt/task/freshness.py +322 -0
- dbt/task/function.py +121 -0
- dbt/task/group_lookup.py +46 -0
- dbt/task/init.py +553 -0
- dbt/task/java.py +316 -0
- dbt/task/list.py +236 -0
- dbt/task/printer.py +175 -0
- dbt/task/retry.py +175 -0
- dbt/task/run.py +1306 -0
- dbt/task/run_operation.py +141 -0
- dbt/task/runnable.py +758 -0
- dbt/task/seed.py +103 -0
- dbt/task/show.py +149 -0
- dbt/task/snapshot.py +56 -0
- dbt/task/spark.py +414 -0
- dbt/task/sql.py +110 -0
- dbt/task/target_sync.py +759 -0
- dbt/task/test.py +464 -0
- dbt/tests/fixtures/__init__.py +1 -0
- dbt/tests/fixtures/project.py +620 -0
- dbt/tests/util.py +651 -0
- dbt/tracking.py +529 -0
- dbt/utils/__init__.py +3 -0
- dbt/utils/artifact_upload.py +151 -0
- dbt/utils/utils.py +408 -0
- dbt/version.py +268 -0
- dvt_cli/__init__.py +72 -0
- dvt_core-0.52.2.dist-info/METADATA +286 -0
- dvt_core-0.52.2.dist-info/RECORD +275 -0
- dvt_core-0.52.2.dist-info/WHEEL +5 -0
- dvt_core-0.52.2.dist-info/entry_points.txt +2 -0
- dvt_core-0.52.2.dist-info/top_level.txt +2 -0
dbt/config/selectors.py
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
from copy import deepcopy
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Any, Dict, Optional, Union
|
|
4
|
+
|
|
5
|
+
from dbt.clients.yaml_helper import Dumper, Loader, load_yaml_text, yaml # noqa: F401
|
|
6
|
+
from dbt.contracts.selection import SelectorFile
|
|
7
|
+
from dbt.exceptions import DbtSelectorsError
|
|
8
|
+
from dbt.graph import SelectionSpec, parse_from_selectors_definition
|
|
9
|
+
from dbt.graph.selector_spec import SelectionCriteria
|
|
10
|
+
from dbt_common.clients.system import (
|
|
11
|
+
load_file_contents,
|
|
12
|
+
path_exists,
|
|
13
|
+
resolve_path_from_base,
|
|
14
|
+
)
|
|
15
|
+
from dbt_common.dataclass_schema import ValidationError
|
|
16
|
+
from dbt_common.exceptions import DbtRuntimeError
|
|
17
|
+
|
|
18
|
+
from .renderer import BaseRenderer
|
|
19
|
+
|
|
20
|
+
MALFORMED_SELECTOR_ERROR = """\
|
|
21
|
+
The selectors.yml file in this project is malformed. Please double check
|
|
22
|
+
the contents of this file and fix any errors before retrying.
|
|
23
|
+
|
|
24
|
+
You can find more information on the syntax for this file here:
|
|
25
|
+
https://docs.getdbt.com/reference/node-selection/yaml-selectors
|
|
26
|
+
|
|
27
|
+
Validator Error:
|
|
28
|
+
{error}
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SelectorConfig(Dict[str, Dict[str, Union[SelectionSpec, bool]]]):
|
|
33
|
+
@classmethod
|
|
34
|
+
def selectors_from_dict(cls, data: Dict[str, Any]) -> "SelectorConfig":
|
|
35
|
+
try:
|
|
36
|
+
SelectorFile.validate(data)
|
|
37
|
+
selector_file = SelectorFile.from_dict(data)
|
|
38
|
+
validate_selector_default(selector_file)
|
|
39
|
+
selectors = parse_from_selectors_definition(selector_file)
|
|
40
|
+
except ValidationError as exc:
|
|
41
|
+
yaml_sel_cfg = yaml.dump(exc.instance)
|
|
42
|
+
raise DbtSelectorsError(
|
|
43
|
+
f"Could not parse selector file data: \n{yaml_sel_cfg}\n"
|
|
44
|
+
f"Valid root-level selector definitions: "
|
|
45
|
+
f"union, intersection, string, dictionary. No lists. "
|
|
46
|
+
f"\nhttps://docs.getdbt.com/reference/node-selection/"
|
|
47
|
+
f"yaml-selectors",
|
|
48
|
+
result_type="invalid_selector",
|
|
49
|
+
) from exc
|
|
50
|
+
except DbtRuntimeError as exc:
|
|
51
|
+
raise DbtSelectorsError(
|
|
52
|
+
f"Could not read selector file data: {exc}",
|
|
53
|
+
result_type="invalid_selector",
|
|
54
|
+
) from exc
|
|
55
|
+
|
|
56
|
+
return cls(selectors)
|
|
57
|
+
|
|
58
|
+
@classmethod
|
|
59
|
+
def render_from_dict(
|
|
60
|
+
cls,
|
|
61
|
+
data: Dict[str, Any],
|
|
62
|
+
renderer: BaseRenderer,
|
|
63
|
+
) -> "SelectorConfig":
|
|
64
|
+
try:
|
|
65
|
+
rendered = renderer.render_data(data)
|
|
66
|
+
except (ValidationError, DbtRuntimeError) as exc:
|
|
67
|
+
raise DbtSelectorsError(
|
|
68
|
+
f"Could not render selector data: {exc}",
|
|
69
|
+
result_type="invalid_selector",
|
|
70
|
+
) from exc
|
|
71
|
+
return cls.selectors_from_dict(rendered)
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def from_path(
|
|
75
|
+
cls,
|
|
76
|
+
path: Path,
|
|
77
|
+
renderer: BaseRenderer,
|
|
78
|
+
) -> "SelectorConfig":
|
|
79
|
+
try:
|
|
80
|
+
data = load_yaml_text(load_file_contents(str(path)))
|
|
81
|
+
if data is None:
|
|
82
|
+
raise ValidationError("No data found in selector file at path: {path}")
|
|
83
|
+
except (ValidationError, DbtRuntimeError) as exc:
|
|
84
|
+
raise DbtSelectorsError(
|
|
85
|
+
f"Could not read selector file: {exc}",
|
|
86
|
+
result_type="invalid_selector",
|
|
87
|
+
path=path,
|
|
88
|
+
) from exc
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
return cls.render_from_dict(data, renderer)
|
|
92
|
+
except DbtSelectorsError as exc:
|
|
93
|
+
exc.path = path
|
|
94
|
+
raise
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def selector_data_from_root(project_root: str) -> Optional[Dict[str, Any]]:
|
|
98
|
+
selector_filepath = resolve_path_from_base("selectors.yml", project_root)
|
|
99
|
+
|
|
100
|
+
if path_exists(selector_filepath):
|
|
101
|
+
selectors_dict = load_yaml_text(load_file_contents(selector_filepath))
|
|
102
|
+
else:
|
|
103
|
+
selectors_dict = None
|
|
104
|
+
return selectors_dict
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def selector_config_from_data(selectors_data: Dict[str, Any]) -> SelectorConfig:
|
|
108
|
+
if not selectors_data:
|
|
109
|
+
selectors_data = {"selectors": []}
|
|
110
|
+
|
|
111
|
+
try:
|
|
112
|
+
selectors = SelectorConfig.selectors_from_dict(selectors_data)
|
|
113
|
+
except ValidationError as e:
|
|
114
|
+
raise DbtSelectorsError(
|
|
115
|
+
MALFORMED_SELECTOR_ERROR.format(error=str(e.message)),
|
|
116
|
+
result_type="invalid_selector",
|
|
117
|
+
) from e
|
|
118
|
+
return selectors
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def validate_selector_default(selector_file: SelectorFile) -> None:
|
|
122
|
+
"""Check if a selector.yml file has more than 1 default key set to true"""
|
|
123
|
+
default_set: bool = False
|
|
124
|
+
default_selector_name: Union[str, None] = None
|
|
125
|
+
|
|
126
|
+
for selector in selector_file.selectors:
|
|
127
|
+
if selector.default is True and default_set is False:
|
|
128
|
+
default_set = True
|
|
129
|
+
default_selector_name = selector.name
|
|
130
|
+
continue
|
|
131
|
+
if selector.default is True and default_set is True:
|
|
132
|
+
raise DbtSelectorsError(
|
|
133
|
+
"Error when parsing the selector file. "
|
|
134
|
+
"Found multiple selectors with `default: true`:"
|
|
135
|
+
f"{default_selector_name} and {selector.name}"
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
# These are utilities to clean up the dictionary created from
|
|
140
|
+
# selectors.yml by turning the cli-string format entries into
|
|
141
|
+
# normalized dictionary entries. It parallels the flow in
|
|
142
|
+
# dbt/graph/cli.py. If changes are made there, it might
|
|
143
|
+
# be necessary to make changes here. Ideally it would be
|
|
144
|
+
# good to combine the two flows into one at some point.
|
|
145
|
+
class SelectorDict:
|
|
146
|
+
@classmethod
|
|
147
|
+
def parse_dict_definition(cls, definition, selector_dict={}):
|
|
148
|
+
key = list(definition)[0]
|
|
149
|
+
value = definition[key]
|
|
150
|
+
if isinstance(value, list):
|
|
151
|
+
new_values = []
|
|
152
|
+
for sel_def in value:
|
|
153
|
+
new_value = cls.parse_from_definition(sel_def, selector_dict=selector_dict)
|
|
154
|
+
new_values.append(new_value)
|
|
155
|
+
value = new_values
|
|
156
|
+
if key == "exclude":
|
|
157
|
+
definition = {key: value}
|
|
158
|
+
elif len(definition) == 1:
|
|
159
|
+
definition = {"method": key, "value": value}
|
|
160
|
+
elif key == "method" and value == "selector":
|
|
161
|
+
sel_def = definition.get("value")
|
|
162
|
+
if sel_def not in selector_dict:
|
|
163
|
+
raise DbtSelectorsError(f"Existing selector definition for {sel_def} not found.")
|
|
164
|
+
return selector_dict[definition["value"]]["definition"]
|
|
165
|
+
return definition
|
|
166
|
+
|
|
167
|
+
@classmethod
|
|
168
|
+
def parse_a_definition(cls, def_type, definition, selector_dict={}):
|
|
169
|
+
# this definition must be a list
|
|
170
|
+
new_dict = {def_type: []}
|
|
171
|
+
for sel_def in definition[def_type]:
|
|
172
|
+
if isinstance(sel_def, dict):
|
|
173
|
+
sel_def = cls.parse_from_definition(sel_def, selector_dict=selector_dict)
|
|
174
|
+
new_dict[def_type].append(sel_def)
|
|
175
|
+
elif isinstance(sel_def, str):
|
|
176
|
+
sel_def = SelectionCriteria.dict_from_single_spec(sel_def)
|
|
177
|
+
new_dict[def_type].append(sel_def)
|
|
178
|
+
else:
|
|
179
|
+
new_dict[def_type].append(sel_def)
|
|
180
|
+
return new_dict
|
|
181
|
+
|
|
182
|
+
@classmethod
|
|
183
|
+
def parse_from_definition(cls, definition, selector_dict={}):
|
|
184
|
+
if isinstance(definition, str):
|
|
185
|
+
definition = SelectionCriteria.dict_from_single_spec(definition)
|
|
186
|
+
elif "union" in definition:
|
|
187
|
+
definition = cls.parse_a_definition("union", definition, selector_dict=selector_dict)
|
|
188
|
+
elif "intersection" in definition:
|
|
189
|
+
definition = cls.parse_a_definition(
|
|
190
|
+
"intersection", definition, selector_dict=selector_dict
|
|
191
|
+
)
|
|
192
|
+
elif isinstance(definition, dict):
|
|
193
|
+
definition = cls.parse_dict_definition(definition, selector_dict=selector_dict)
|
|
194
|
+
return definition
|
|
195
|
+
|
|
196
|
+
# This is the normal entrypoint of this code. Give it the
|
|
197
|
+
# list of selectors generated from the selectors.yml file.
|
|
198
|
+
@classmethod
|
|
199
|
+
def parse_from_selectors_list(cls, selectors):
|
|
200
|
+
selector_dict = {}
|
|
201
|
+
for selector in selectors:
|
|
202
|
+
sel_name = selector["name"]
|
|
203
|
+
selector_dict[sel_name] = selector
|
|
204
|
+
definition = cls.parse_from_definition(
|
|
205
|
+
selector["definition"], selector_dict=deepcopy(selector_dict)
|
|
206
|
+
)
|
|
207
|
+
selector_dict[sel_name]["definition"] = definition
|
|
208
|
+
return selector_dict
|
dbt/config/utils.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
from typing import Any, Dict, Optional
|
|
2
|
+
|
|
3
|
+
from dbt import deprecations
|
|
4
|
+
from dbt.clients import yaml_helper
|
|
5
|
+
from dbt.events.types import InvalidOptionYAML
|
|
6
|
+
from dbt.exceptions import DbtExclusivePropertyUseError, OptionNotYamlDictError
|
|
7
|
+
from dbt_common.events.functions import fire_event
|
|
8
|
+
from dbt_common.exceptions import DbtValidationError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def parse_cli_vars(var_string: str) -> Dict[str, Any]:
|
|
12
|
+
return parse_cli_yaml_string(var_string, "vars")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def parse_cli_yaml_string(var_string: str, cli_option_name: str) -> Dict[str, Any]:
|
|
16
|
+
try:
|
|
17
|
+
cli_vars = yaml_helper.load_yaml_text(var_string)
|
|
18
|
+
var_type = type(cli_vars)
|
|
19
|
+
if cli_vars is not None and var_type is dict:
|
|
20
|
+
return cli_vars
|
|
21
|
+
else:
|
|
22
|
+
raise OptionNotYamlDictError(var_type, cli_option_name)
|
|
23
|
+
except (DbtValidationError, OptionNotYamlDictError):
|
|
24
|
+
fire_event(InvalidOptionYAML(option_name=cli_option_name))
|
|
25
|
+
raise
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def exclusive_primary_alt_value_setting(
|
|
29
|
+
dictionary: Optional[Dict[str, Any]],
|
|
30
|
+
primary: str,
|
|
31
|
+
alt: str,
|
|
32
|
+
parent_config: Optional[str] = None,
|
|
33
|
+
) -> None:
|
|
34
|
+
"""Munges in place under the primary the options for the primary and alt values
|
|
35
|
+
|
|
36
|
+
Sometimes we allow setting something via TWO keys, but not at the same time. If both the primary
|
|
37
|
+
key and alt key have values, an error gets raised. If the alt key has values, then we update
|
|
38
|
+
the dictionary to ensure the primary key contains the values. If neither are set, nothing happens.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
if dictionary is None:
|
|
42
|
+
return
|
|
43
|
+
|
|
44
|
+
primary_options = dictionary.get(primary)
|
|
45
|
+
alt_options = dictionary.get(alt)
|
|
46
|
+
|
|
47
|
+
if primary_options and alt_options:
|
|
48
|
+
where = f" in `{parent_config}`" if parent_config is not None else ""
|
|
49
|
+
raise DbtExclusivePropertyUseError(
|
|
50
|
+
f"Only `{alt}` or `{primary}` can be specified{where}, not both"
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
if alt in dictionary:
|
|
54
|
+
alt_value = dictionary.pop(alt)
|
|
55
|
+
dictionary[primary] = alt_value
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def normalize_warn_error_options(warn_error_options: Dict[str, Any]) -> None:
|
|
59
|
+
has_include = "include" in warn_error_options
|
|
60
|
+
has_exclude = "exclude" in warn_error_options
|
|
61
|
+
|
|
62
|
+
if has_include or has_exclude:
|
|
63
|
+
deprecations.buffer(
|
|
64
|
+
"weo-include-exclude-deprecation",
|
|
65
|
+
found_include=has_include,
|
|
66
|
+
found_exclude=has_exclude,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
exclusive_primary_alt_value_setting(
|
|
70
|
+
warn_error_options, "error", "include", "warn_error_options"
|
|
71
|
+
)
|
|
72
|
+
exclusive_primary_alt_value_setting(
|
|
73
|
+
warn_error_options, "warn", "exclude", "warn_error_options"
|
|
74
|
+
)
|
|
75
|
+
for key in ("error", "warn", "silence"):
|
|
76
|
+
if key in warn_error_options and warn_error_options[key] is None:
|
|
77
|
+
warn_error_options[key] = []
|
dbt/constants.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from dbt_semantic_interfaces.type_enums import TimeGranularity
|
|
2
|
+
|
|
3
|
+
DEFAULT_ENV_PLACEHOLDER = "DBT_DEFAULT_PLACEHOLDER"
|
|
4
|
+
|
|
5
|
+
SECRET_PLACEHOLDER = "$$$DBT_SECRET_START$$${}$$$DBT_SECRET_END$$$"
|
|
6
|
+
|
|
7
|
+
MAXIMUM_SEED_SIZE = 1 * 1024 * 1024
|
|
8
|
+
MAXIMUM_SEED_SIZE_NAME = "1MB"
|
|
9
|
+
|
|
10
|
+
PIN_PACKAGE_URL = (
|
|
11
|
+
"https://docs.getdbt.com/docs/package-management#section-specifying-package-versions"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
DBT_PROJECT_FILE_NAME = "dbt_project.yml"
|
|
15
|
+
PACKAGES_FILE_NAME = "packages.yml"
|
|
16
|
+
DEPENDENCIES_FILE_NAME = "dependencies.yml"
|
|
17
|
+
PACKAGE_LOCK_FILE_NAME = "package-lock.yml"
|
|
18
|
+
MANIFEST_FILE_NAME = "manifest.json"
|
|
19
|
+
SEMANTIC_MANIFEST_FILE_NAME = "semantic_manifest.json"
|
|
20
|
+
LEGACY_TIME_SPINE_MODEL_NAME = "metricflow_time_spine"
|
|
21
|
+
LEGACY_TIME_SPINE_GRANULARITY = TimeGranularity.DAY
|
|
22
|
+
MINIMUM_REQUIRED_TIME_SPINE_GRANULARITY = TimeGranularity.DAY
|
|
23
|
+
PARTIAL_PARSE_FILE_NAME = "partial_parse.msgpack"
|
|
24
|
+
PACKAGE_LOCK_HASH_KEY = "sha1_hash"
|
|
25
|
+
CATALOGS_FILE_NAME = "catalogs.yml"
|
|
26
|
+
RUN_RESULTS_FILE_NAME = "run_results.json"
|
|
27
|
+
CATALOG_FILENAME = "catalog.json"
|
|
28
|
+
SOURCE_RESULT_FILE_NAME = "sources.json"
|
dbt/context/__init__.py
ADDED
|
File without changes
|