dvt-core 0.58.6__cp311-cp311-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 +2403 -0
- dbt/cli/option_types.py +121 -0
- dbt/cli/options.py +80 -0
- dbt/cli/params.py +844 -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.cpython-311-darwin.so +0 -0
- dbt/compute/engines/spark_engine.py +642 -0
- dbt/compute/federated_executor.cpython-311-darwin.so +0 -0
- dbt/compute/federated_executor.py +1080 -0
- dbt/compute/filter_pushdown.cpython-311-darwin.so +0 -0
- dbt/compute/filter_pushdown.py +273 -0
- dbt/compute/jar_provisioning.cpython-311-darwin.so +0 -0
- dbt/compute/jar_provisioning.py +255 -0
- dbt/compute/java_compat.cpython-311-darwin.so +0 -0
- dbt/compute/java_compat.py +689 -0
- dbt/compute/jdbc_utils.cpython-311-darwin.so +0 -0
- dbt/compute/jdbc_utils.py +678 -0
- dbt/compute/metadata/__init__.py +40 -0
- dbt/compute/metadata/adapters_registry.cpython-311-darwin.so +0 -0
- dbt/compute/metadata/adapters_registry.py +370 -0
- dbt/compute/metadata/registry.cpython-311-darwin.so +0 -0
- dbt/compute/metadata/registry.py +674 -0
- dbt/compute/metadata/store.cpython-311-darwin.so +0 -0
- dbt/compute/metadata/store.py +1499 -0
- dbt/compute/smart_selector.cpython-311-darwin.so +0 -0
- dbt/compute/smart_selector.py +377 -0
- dbt/compute/strategies/__init__.py +55 -0
- dbt/compute/strategies/base.cpython-311-darwin.so +0 -0
- dbt/compute/strategies/base.py +165 -0
- dbt/compute/strategies/dataproc.cpython-311-darwin.so +0 -0
- dbt/compute/strategies/dataproc.py +207 -0
- dbt/compute/strategies/emr.cpython-311-darwin.so +0 -0
- dbt/compute/strategies/emr.py +203 -0
- dbt/compute/strategies/local.cpython-311-darwin.so +0 -0
- dbt/compute/strategies/local.py +443 -0
- dbt/compute/strategies/standalone.cpython-311-darwin.so +0 -0
- dbt/compute/strategies/standalone.py +262 -0
- dbt/config/__init__.py +4 -0
- dbt/config/catalogs.py +94 -0
- dbt/config/compute.cpython-311-darwin.so +0 -0
- dbt/config/compute.py +513 -0
- dbt/config/dvt_profile.cpython-311-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 +348 -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 +249 -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/data/adapters_registry.duckdb +0 -0
- dbt/include/data/build_registry.py +242 -0
- dbt/include/data/csv/adapter_queries.csv +33 -0
- dbt/include/data/csv/syntax_rules.csv +9 -0
- dbt/include/data/csv/type_mappings_bigquery.csv +28 -0
- dbt/include/data/csv/type_mappings_databricks.csv +30 -0
- dbt/include/data/csv/type_mappings_mysql.csv +40 -0
- dbt/include/data/csv/type_mappings_oracle.csv +30 -0
- dbt/include/data/csv/type_mappings_postgres.csv +56 -0
- dbt/include/data/csv/type_mappings_redshift.csv +33 -0
- dbt/include/data/csv/type_mappings_snowflake.csv +38 -0
- dbt/include/data/csv/type_mappings_sqlserver.csv +35 -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-311-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.cpython-311-darwin.so +0 -0
- dbt/task/compute.py +458 -0
- dbt/task/debug.py +505 -0
- dbt/task/deps.py +280 -0
- dbt/task/docs/__init__.py +3 -0
- dbt/task/docs/api/__init__.py +23 -0
- dbt/task/docs/api/catalog.cpython-311-darwin.so +0 -0
- dbt/task/docs/api/catalog.py +204 -0
- dbt/task/docs/api/lineage.cpython-311-darwin.so +0 -0
- dbt/task/docs/api/lineage.py +234 -0
- dbt/task/docs/api/profile.cpython-311-darwin.so +0 -0
- dbt/task/docs/api/profile.py +204 -0
- dbt/task/docs/api/spark.cpython-311-darwin.so +0 -0
- dbt/task/docs/api/spark.py +186 -0
- dbt/task/docs/generate.py +947 -0
- dbt/task/docs/index.html +250 -0
- dbt/task/docs/serve.cpython-311-darwin.so +0 -0
- dbt/task/docs/serve.py +174 -0
- dbt/task/dvt_output.py +362 -0
- dbt/task/dvt_run.py +204 -0
- dbt/task/freshness.py +322 -0
- dbt/task/function.py +121 -0
- dbt/task/group_lookup.py +46 -0
- dbt/task/init.cpython-311-darwin.so +0 -0
- dbt/task/init.py +604 -0
- dbt/task/java.cpython-311-darwin.so +0 -0
- dbt/task/java.py +316 -0
- dbt/task/list.py +236 -0
- dbt/task/metadata.cpython-311-darwin.so +0 -0
- dbt/task/metadata.py +804 -0
- dbt/task/printer.py +175 -0
- dbt/task/profile.cpython-311-darwin.so +0 -0
- dbt/task/profile.py +1307 -0
- dbt/task/profile_serve.py +615 -0
- dbt/task/retract.py +438 -0
- dbt/task/retry.py +175 -0
- dbt/task/run.py +1387 -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.cpython-311-darwin.so +0 -0
- dbt/task/spark.py +414 -0
- dbt/task/sql.py +110 -0
- dbt/task/target_sync.cpython-311-darwin.so +0 -0
- dbt/task/target_sync.py +766 -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 +270 -0
- dvt_cli/__init__.py +72 -0
- dvt_core-0.58.6.dist-info/METADATA +288 -0
- dvt_core-0.58.6.dist-info/RECORD +324 -0
- dvt_core-0.58.6.dist-info/WHEEL +5 -0
- dvt_core-0.58.6.dist-info/entry_points.txt +2 -0
- dvt_core-0.58.6.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
def rename_sql_attr(node_content: dict) -> dict:
|
|
2
|
+
if "raw_sql" in node_content:
|
|
3
|
+
node_content["raw_code"] = node_content.pop("raw_sql")
|
|
4
|
+
if "compiled_sql" in node_content:
|
|
5
|
+
node_content["compiled_code"] = node_content.pop("compiled_sql")
|
|
6
|
+
node_content["language"] = "sql"
|
|
7
|
+
return node_content
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def upgrade_ref_content(node_content: dict) -> dict:
|
|
11
|
+
# In v1.5 we switched Node.refs from List[List[str]] to List[Dict[str, Union[NodeVersion, str]]]
|
|
12
|
+
# Previous versions did not have a version keyword argument for ref
|
|
13
|
+
if "refs" in node_content:
|
|
14
|
+
upgraded_refs = []
|
|
15
|
+
for ref in node_content["refs"]:
|
|
16
|
+
if isinstance(ref, list):
|
|
17
|
+
if len(ref) == 1:
|
|
18
|
+
upgraded_refs.append({"package": None, "name": ref[0], "version": None})
|
|
19
|
+
else:
|
|
20
|
+
upgraded_refs.append({"package": ref[0], "name": ref[1], "version": None})
|
|
21
|
+
node_content["refs"] = upgraded_refs
|
|
22
|
+
return node_content
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def upgrade_node_content(node_content):
|
|
26
|
+
rename_sql_attr(node_content)
|
|
27
|
+
upgrade_ref_content(node_content)
|
|
28
|
+
if node_content["resource_type"] != "seed" and "root_path" in node_content:
|
|
29
|
+
del node_content["root_path"]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def upgrade_seed_content(node_content):
|
|
33
|
+
# Remove compilation related attributes
|
|
34
|
+
for attr_name in (
|
|
35
|
+
"language",
|
|
36
|
+
"refs",
|
|
37
|
+
"sources",
|
|
38
|
+
"metrics",
|
|
39
|
+
"compiled_path",
|
|
40
|
+
"compiled",
|
|
41
|
+
"compiled_code",
|
|
42
|
+
"extra_ctes_injected",
|
|
43
|
+
"extra_ctes",
|
|
44
|
+
"relation_name",
|
|
45
|
+
):
|
|
46
|
+
if attr_name in node_content:
|
|
47
|
+
del node_content[attr_name]
|
|
48
|
+
# In v1.4, we switched SeedNode.depends_on from DependsOn to MacroDependsOn
|
|
49
|
+
node_content.get("depends_on", {}).pop("nodes", None)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def drop_v9_and_prior_metrics(manifest: dict) -> None:
|
|
53
|
+
manifest["metrics"] = {}
|
|
54
|
+
filtered_disabled_entries = {}
|
|
55
|
+
for entry_name, resource_list in manifest.get("disabled", {}).items():
|
|
56
|
+
filtered_resource_list = []
|
|
57
|
+
for resource in resource_list:
|
|
58
|
+
if resource.get("resource_type") != "metric":
|
|
59
|
+
filtered_resource_list.append(resource)
|
|
60
|
+
filtered_disabled_entries[entry_name] = filtered_resource_list
|
|
61
|
+
|
|
62
|
+
manifest["disabled"] = filtered_disabled_entries
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _convert_dct_with_filter(v10_dct_with_opt_filter):
|
|
66
|
+
"""Upgrage the filter object from v10 to v11.
|
|
67
|
+
|
|
68
|
+
v10 filters from a serialized manifest looked like:
|
|
69
|
+
{..., 'filter': {'where_sql_template': '<filter_value>'}}
|
|
70
|
+
whereas v11 filters look like:
|
|
71
|
+
{..., 'filter': {'where_filters': [{'where_sql_template': '<filter_value>'}, ...]}}
|
|
72
|
+
"""
|
|
73
|
+
if v10_dct_with_opt_filter is not None and v10_dct_with_opt_filter.get("filter") is not None:
|
|
74
|
+
v10_dct_with_opt_filter["filter"] = {"where_filters": [v10_dct_with_opt_filter["filter"]]}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _convert_metric(v10_metric_dict):
|
|
78
|
+
"""Upgrades a v10 metric object to a v11 metric object.
|
|
79
|
+
|
|
80
|
+
Specifcally the following properties change
|
|
81
|
+
1. metric.filter
|
|
82
|
+
2. metric.type_params.measure.filter
|
|
83
|
+
3. metric.type_params.input_measures[x].filter
|
|
84
|
+
4. metric.type_params.numerator.filter
|
|
85
|
+
5. metric.type_params.denominator.filter
|
|
86
|
+
6. metric.type_params.metrics[x].filter"
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
# handles top level metric filter
|
|
90
|
+
_convert_dct_with_filter(v10_metric_dict)
|
|
91
|
+
|
|
92
|
+
type_params = v10_metric_dict.get("type_params")
|
|
93
|
+
if type_params is not None:
|
|
94
|
+
_convert_dct_with_filter(type_params.get("measure"))
|
|
95
|
+
_convert_dct_with_filter(type_params.get("numerator"))
|
|
96
|
+
_convert_dct_with_filter(type_params.get("denominator"))
|
|
97
|
+
|
|
98
|
+
# handles metric.type_params.input_measures[x].filter
|
|
99
|
+
input_measures = type_params.get("input_measures")
|
|
100
|
+
if input_measures is not None:
|
|
101
|
+
for input_measure in input_measures:
|
|
102
|
+
_convert_dct_with_filter(input_measure)
|
|
103
|
+
|
|
104
|
+
# handles metric.type_params.metrics[x].filter
|
|
105
|
+
metrics = type_params.get("metrics")
|
|
106
|
+
if metrics is not None:
|
|
107
|
+
for metric in metrics:
|
|
108
|
+
_convert_dct_with_filter(metric)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def upgrade_v10_metric_filters(manifest: dict):
|
|
112
|
+
"""Handles metric filters changes from v10 to v11."""
|
|
113
|
+
|
|
114
|
+
metrics = manifest.get("metrics", {})
|
|
115
|
+
for metric in metrics.values():
|
|
116
|
+
_convert_metric(metric)
|
|
117
|
+
|
|
118
|
+
disabled_nodes = manifest.get("disabled", {})
|
|
119
|
+
for unique_id, nodes in disabled_nodes.items():
|
|
120
|
+
if unique_id.split(".")[0] == "metric":
|
|
121
|
+
for node in nodes:
|
|
122
|
+
_convert_metric(node)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def upgrade_manifest_json(manifest: dict, manifest_schema_version: int) -> dict:
|
|
126
|
+
# this should remain 9 while the check in `upgrade_schema_version` may change
|
|
127
|
+
if manifest_schema_version <= 9:
|
|
128
|
+
drop_v9_and_prior_metrics(manifest=manifest)
|
|
129
|
+
elif manifest_schema_version == 10:
|
|
130
|
+
upgrade_v10_metric_filters(manifest=manifest)
|
|
131
|
+
|
|
132
|
+
for node_content in manifest.get("nodes", {}).values():
|
|
133
|
+
upgrade_node_content(node_content)
|
|
134
|
+
if node_content["resource_type"] == "seed":
|
|
135
|
+
upgrade_seed_content(node_content)
|
|
136
|
+
for disabled in manifest.get("disabled", {}).values():
|
|
137
|
+
# There can be multiple disabled nodes for the same unique_id
|
|
138
|
+
# so make sure all the nodes get the attr renamed
|
|
139
|
+
for node_content in disabled:
|
|
140
|
+
upgrade_node_content(node_content)
|
|
141
|
+
if node_content["resource_type"] == "seed":
|
|
142
|
+
upgrade_seed_content(node_content)
|
|
143
|
+
# add group key
|
|
144
|
+
if "groups" not in manifest:
|
|
145
|
+
manifest["groups"] = {}
|
|
146
|
+
if "group_map" not in manifest:
|
|
147
|
+
manifest["group_map"] = {}
|
|
148
|
+
# add unit_tests key
|
|
149
|
+
if "unit_tests" not in manifest:
|
|
150
|
+
manifest["unit_tests"] = {}
|
|
151
|
+
for metric_content in manifest.get("metrics", {}).values():
|
|
152
|
+
# handle attr renames + value translation ("expression" -> "derived")
|
|
153
|
+
metric_content = upgrade_ref_content(metric_content)
|
|
154
|
+
if "root_path" in metric_content:
|
|
155
|
+
del metric_content["root_path"]
|
|
156
|
+
for exposure_content in manifest.get("exposures", {}).values():
|
|
157
|
+
exposure_content = upgrade_ref_content(exposure_content)
|
|
158
|
+
if "root_path" in exposure_content:
|
|
159
|
+
del exposure_content["root_path"]
|
|
160
|
+
for source_content in manifest.get("sources", {}).values():
|
|
161
|
+
if "root_path" in source_content:
|
|
162
|
+
del source_content["root_path"]
|
|
163
|
+
for macro_content in manifest.get("macros", {}).values():
|
|
164
|
+
if "root_path" in macro_content:
|
|
165
|
+
del macro_content["root_path"]
|
|
166
|
+
for doc_content in manifest.get("docs", {}).values():
|
|
167
|
+
if "root_path" in doc_content:
|
|
168
|
+
del doc_content["root_path"]
|
|
169
|
+
doc_content["resource_type"] = "doc"
|
|
170
|
+
if "semantic_models" not in manifest:
|
|
171
|
+
manifest["semantic_models"] = {}
|
|
172
|
+
if "saved_queries" not in manifest:
|
|
173
|
+
manifest["saved_queries"] = {}
|
|
174
|
+
return manifest
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
3
|
+
HTML_COLORS = [
|
|
4
|
+
"aliceblue",
|
|
5
|
+
"antiquewhite",
|
|
6
|
+
"aqua",
|
|
7
|
+
"aquamarine",
|
|
8
|
+
"azure",
|
|
9
|
+
"beige",
|
|
10
|
+
"bisque",
|
|
11
|
+
"black",
|
|
12
|
+
"blanchedalmond",
|
|
13
|
+
"blue",
|
|
14
|
+
"blueviolet",
|
|
15
|
+
"brown",
|
|
16
|
+
"burlywood",
|
|
17
|
+
"cadetblue",
|
|
18
|
+
"chartreuse",
|
|
19
|
+
"chocolate",
|
|
20
|
+
"coral",
|
|
21
|
+
"cornflowerblue",
|
|
22
|
+
"cornsilk",
|
|
23
|
+
"crimson",
|
|
24
|
+
"cyan",
|
|
25
|
+
"darkblue",
|
|
26
|
+
"darkcyan",
|
|
27
|
+
"darkgoldenrod",
|
|
28
|
+
"darkgray",
|
|
29
|
+
"darkgreen",
|
|
30
|
+
"darkkhaki",
|
|
31
|
+
"darkmagenta",
|
|
32
|
+
"darkolivegreen",
|
|
33
|
+
"darkorange",
|
|
34
|
+
"darkorchid",
|
|
35
|
+
"darkred",
|
|
36
|
+
"darksalmon",
|
|
37
|
+
"darkseagreen",
|
|
38
|
+
"darkslateblue",
|
|
39
|
+
"darkslategray",
|
|
40
|
+
"darkturquoise",
|
|
41
|
+
"darkviolet",
|
|
42
|
+
"deeppink",
|
|
43
|
+
"deepskyblue",
|
|
44
|
+
"dimgray",
|
|
45
|
+
"dodgerblue",
|
|
46
|
+
"firebrick",
|
|
47
|
+
"floralwhite",
|
|
48
|
+
"forestgreen",
|
|
49
|
+
"fuchsia",
|
|
50
|
+
"gainsboro",
|
|
51
|
+
"ghostwhite",
|
|
52
|
+
"gold",
|
|
53
|
+
"goldenrod",
|
|
54
|
+
"gray",
|
|
55
|
+
"green",
|
|
56
|
+
"greenyellow",
|
|
57
|
+
"honeydew",
|
|
58
|
+
"hotpink",
|
|
59
|
+
"indianred",
|
|
60
|
+
"indigo",
|
|
61
|
+
"ivory",
|
|
62
|
+
"khaki",
|
|
63
|
+
"lavender",
|
|
64
|
+
"lavenderblush",
|
|
65
|
+
"lawngreen",
|
|
66
|
+
"lemonchiffon",
|
|
67
|
+
"lightblue",
|
|
68
|
+
"lightcoral",
|
|
69
|
+
"lightcyan",
|
|
70
|
+
"lightgoldenrodyellow",
|
|
71
|
+
"lightgray",
|
|
72
|
+
"lightgreen",
|
|
73
|
+
"lightpink",
|
|
74
|
+
"lightsalmon",
|
|
75
|
+
"lightsalmon",
|
|
76
|
+
"lightseagreen",
|
|
77
|
+
"lightskyblue",
|
|
78
|
+
"lightslategray",
|
|
79
|
+
"lightsteelblue",
|
|
80
|
+
"lightyellow",
|
|
81
|
+
"lime",
|
|
82
|
+
"limegreen",
|
|
83
|
+
"linen",
|
|
84
|
+
"magenta",
|
|
85
|
+
"maroon",
|
|
86
|
+
"mediumaquamarine",
|
|
87
|
+
"mediumblue",
|
|
88
|
+
"mediumorchid",
|
|
89
|
+
"mediumpurple",
|
|
90
|
+
"mediumseagreen",
|
|
91
|
+
"mediumslateblue",
|
|
92
|
+
"mediumslateblue",
|
|
93
|
+
"mediumspringgreen",
|
|
94
|
+
"mediumturquoise",
|
|
95
|
+
"mediumvioletred",
|
|
96
|
+
"midnightblue",
|
|
97
|
+
"mintcream",
|
|
98
|
+
"mistyrose",
|
|
99
|
+
"moccasin",
|
|
100
|
+
"navajowhite",
|
|
101
|
+
"navy",
|
|
102
|
+
"oldlace",
|
|
103
|
+
"olive",
|
|
104
|
+
"olivedrab",
|
|
105
|
+
"orange",
|
|
106
|
+
"orangered",
|
|
107
|
+
"orchid",
|
|
108
|
+
"palegoldenrod",
|
|
109
|
+
"palegreen",
|
|
110
|
+
"paleturquoise",
|
|
111
|
+
"palevioletred",
|
|
112
|
+
"papayawhip",
|
|
113
|
+
"peachpuff",
|
|
114
|
+
"peru",
|
|
115
|
+
"pink",
|
|
116
|
+
"plum",
|
|
117
|
+
"powderblue",
|
|
118
|
+
"purple",
|
|
119
|
+
"rebeccapurple",
|
|
120
|
+
"red",
|
|
121
|
+
"rosybrown",
|
|
122
|
+
"royalblue",
|
|
123
|
+
"saddlebrown",
|
|
124
|
+
"salmon",
|
|
125
|
+
"sandybrown",
|
|
126
|
+
"seagreen",
|
|
127
|
+
"seashell",
|
|
128
|
+
"sienna",
|
|
129
|
+
"silver",
|
|
130
|
+
"skyblue",
|
|
131
|
+
"slateblue",
|
|
132
|
+
"slategray",
|
|
133
|
+
"snow",
|
|
134
|
+
"springgreen",
|
|
135
|
+
"steelblue",
|
|
136
|
+
"tan",
|
|
137
|
+
"teal",
|
|
138
|
+
"thistle",
|
|
139
|
+
"tomato",
|
|
140
|
+
"turquoise",
|
|
141
|
+
"violet",
|
|
142
|
+
"wheat",
|
|
143
|
+
"white",
|
|
144
|
+
"whitesmoke",
|
|
145
|
+
"yellow",
|
|
146
|
+
"yellowgreen",
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def validate_color(color: str) -> bool:
|
|
151
|
+
match_hex = re.search(r"^#(?:[0-9a-f]{3}){1,2}$", color.lower())
|
|
152
|
+
match_html_color_name = color.lower() in HTML_COLORS
|
|
153
|
+
return bool(match_hex or match_html_color_name)
|
dbt/cli/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .main import cli as dbt_cli # noqa
|
dbt/cli/context.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from dbt.cli.main import cli as dbt
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def make_context(args, command=dbt) -> Optional[click.Context]:
|
|
9
|
+
try:
|
|
10
|
+
ctx = command.make_context(command.name, args)
|
|
11
|
+
except click.exceptions.Exit:
|
|
12
|
+
return None
|
|
13
|
+
|
|
14
|
+
ctx.invoked_subcommand = ctx.protected_args[0] if ctx.protected_args else None
|
|
15
|
+
ctx.obj = {}
|
|
16
|
+
|
|
17
|
+
return ctx
|
dbt/cli/exceptions.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from typing import IO, List, Optional, Union
|
|
2
|
+
|
|
3
|
+
from click.exceptions import ClickException
|
|
4
|
+
|
|
5
|
+
from dbt.artifacts.schemas.catalog import CatalogArtifact
|
|
6
|
+
from dbt.contracts.graph.manifest import Manifest
|
|
7
|
+
from dbt.contracts.results import RunExecutionResult
|
|
8
|
+
from dbt.utils import ExitCodes
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class DbtUsageException(Exception):
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class DbtInternalException(Exception):
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CliException(ClickException):
|
|
20
|
+
"""The base exception class for our implementation of the click CLI.
|
|
21
|
+
The exit_code attribute is used by click to determine which exit code to produce
|
|
22
|
+
after an invocation."""
|
|
23
|
+
|
|
24
|
+
def __init__(self, exit_code: ExitCodes) -> None:
|
|
25
|
+
self.exit_code = exit_code.value
|
|
26
|
+
|
|
27
|
+
# the typing of _file is to satisfy the signature of ClickException.show
|
|
28
|
+
# overriding this method prevents click from printing any exceptions to stdout
|
|
29
|
+
def show(self, _file: Optional[IO] = None) -> None: # type: ignore[type-arg]
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ResultExit(CliException):
|
|
34
|
+
"""This class wraps any exception that contains results while invoking dbt, or the
|
|
35
|
+
results of an invocation that did not succeed but did not throw any exceptions."""
|
|
36
|
+
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
result: Union[
|
|
40
|
+
bool, # debug
|
|
41
|
+
CatalogArtifact, # docs generate
|
|
42
|
+
List[str], # list/ls
|
|
43
|
+
Manifest, # parse
|
|
44
|
+
None, # clean, deps, init, source
|
|
45
|
+
RunExecutionResult, # build, compile, run, seed, snapshot, test, run-operation
|
|
46
|
+
] = None,
|
|
47
|
+
) -> None:
|
|
48
|
+
super().__init__(ExitCodes.ModelError)
|
|
49
|
+
self.result = result
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ExceptionExit(CliException):
|
|
53
|
+
"""This class wraps any exception that does not contain results thrown while invoking dbt."""
|
|
54
|
+
|
|
55
|
+
def __init__(self, exception: Exception) -> None:
|
|
56
|
+
super().__init__(ExitCodes.UnhandledError)
|
|
57
|
+
self.exception = exception
|