dvt-core 1.11.0b4__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.

Potentially problematic release.


This version of dvt-core might be problematic. Click here for more details.

Files changed (261) hide show
  1. dvt/__init__.py +7 -0
  2. dvt/_pydantic_shim.py +26 -0
  3. dvt/adapters/__init__.py +16 -0
  4. dvt/adapters/multi_adapter_manager.py +268 -0
  5. dvt/artifacts/__init__.py +0 -0
  6. dvt/artifacts/exceptions/__init__.py +1 -0
  7. dvt/artifacts/exceptions/schemas.py +31 -0
  8. dvt/artifacts/resources/__init__.py +116 -0
  9. dvt/artifacts/resources/base.py +68 -0
  10. dvt/artifacts/resources/types.py +93 -0
  11. dvt/artifacts/resources/v1/analysis.py +10 -0
  12. dvt/artifacts/resources/v1/catalog.py +23 -0
  13. dvt/artifacts/resources/v1/components.py +275 -0
  14. dvt/artifacts/resources/v1/config.py +282 -0
  15. dvt/artifacts/resources/v1/documentation.py +11 -0
  16. dvt/artifacts/resources/v1/exposure.py +52 -0
  17. dvt/artifacts/resources/v1/function.py +53 -0
  18. dvt/artifacts/resources/v1/generic_test.py +32 -0
  19. dvt/artifacts/resources/v1/group.py +22 -0
  20. dvt/artifacts/resources/v1/hook.py +11 -0
  21. dvt/artifacts/resources/v1/macro.py +30 -0
  22. dvt/artifacts/resources/v1/metric.py +173 -0
  23. dvt/artifacts/resources/v1/model.py +146 -0
  24. dvt/artifacts/resources/v1/owner.py +10 -0
  25. dvt/artifacts/resources/v1/saved_query.py +112 -0
  26. dvt/artifacts/resources/v1/seed.py +42 -0
  27. dvt/artifacts/resources/v1/semantic_layer_components.py +72 -0
  28. dvt/artifacts/resources/v1/semantic_model.py +315 -0
  29. dvt/artifacts/resources/v1/singular_test.py +14 -0
  30. dvt/artifacts/resources/v1/snapshot.py +92 -0
  31. dvt/artifacts/resources/v1/source_definition.py +85 -0
  32. dvt/artifacts/resources/v1/sql_operation.py +10 -0
  33. dvt/artifacts/resources/v1/unit_test_definition.py +78 -0
  34. dvt/artifacts/schemas/__init__.py +0 -0
  35. dvt/artifacts/schemas/base.py +191 -0
  36. dvt/artifacts/schemas/batch_results.py +24 -0
  37. dvt/artifacts/schemas/catalog/__init__.py +12 -0
  38. dvt/artifacts/schemas/catalog/v1/__init__.py +0 -0
  39. dvt/artifacts/schemas/catalog/v1/catalog.py +60 -0
  40. dvt/artifacts/schemas/freshness/__init__.py +1 -0
  41. dvt/artifacts/schemas/freshness/v3/__init__.py +0 -0
  42. dvt/artifacts/schemas/freshness/v3/freshness.py +159 -0
  43. dvt/artifacts/schemas/manifest/__init__.py +2 -0
  44. dvt/artifacts/schemas/manifest/v12/__init__.py +0 -0
  45. dvt/artifacts/schemas/manifest/v12/manifest.py +212 -0
  46. dvt/artifacts/schemas/results.py +148 -0
  47. dvt/artifacts/schemas/run/__init__.py +2 -0
  48. dvt/artifacts/schemas/run/v5/__init__.py +0 -0
  49. dvt/artifacts/schemas/run/v5/run.py +184 -0
  50. dvt/artifacts/schemas/upgrades/__init__.py +4 -0
  51. dvt/artifacts/schemas/upgrades/upgrade_manifest.py +174 -0
  52. dvt/artifacts/schemas/upgrades/upgrade_manifest_dbt_version.py +2 -0
  53. dvt/artifacts/utils/validation.py +153 -0
  54. dvt/cli/__init__.py +1 -0
  55. dvt/cli/context.py +16 -0
  56. dvt/cli/exceptions.py +56 -0
  57. dvt/cli/flags.py +558 -0
  58. dvt/cli/main.py +971 -0
  59. dvt/cli/option_types.py +121 -0
  60. dvt/cli/options.py +79 -0
  61. dvt/cli/params.py +803 -0
  62. dvt/cli/requires.py +478 -0
  63. dvt/cli/resolvers.py +32 -0
  64. dvt/cli/types.py +40 -0
  65. dvt/clients/__init__.py +0 -0
  66. dvt/clients/checked_load.py +82 -0
  67. dvt/clients/git.py +164 -0
  68. dvt/clients/jinja.py +206 -0
  69. dvt/clients/jinja_static.py +245 -0
  70. dvt/clients/registry.py +192 -0
  71. dvt/clients/yaml_helper.py +68 -0
  72. dvt/compilation.py +833 -0
  73. dvt/compute/__init__.py +26 -0
  74. dvt/compute/base.py +288 -0
  75. dvt/compute/engines/__init__.py +13 -0
  76. dvt/compute/engines/duckdb_engine.py +368 -0
  77. dvt/compute/engines/spark_engine.py +273 -0
  78. dvt/compute/query_analyzer.py +212 -0
  79. dvt/compute/router.py +483 -0
  80. dvt/config/__init__.py +4 -0
  81. dvt/config/catalogs.py +95 -0
  82. dvt/config/compute_config.py +406 -0
  83. dvt/config/profile.py +411 -0
  84. dvt/config/profiles_v2.py +464 -0
  85. dvt/config/project.py +893 -0
  86. dvt/config/renderer.py +232 -0
  87. dvt/config/runtime.py +491 -0
  88. dvt/config/selectors.py +209 -0
  89. dvt/config/utils.py +78 -0
  90. dvt/connectors/.gitignore +6 -0
  91. dvt/connectors/README.md +306 -0
  92. dvt/connectors/catalog.yml +217 -0
  93. dvt/connectors/download_connectors.py +300 -0
  94. dvt/constants.py +29 -0
  95. dvt/context/__init__.py +0 -0
  96. dvt/context/base.py +746 -0
  97. dvt/context/configured.py +136 -0
  98. dvt/context/context_config.py +350 -0
  99. dvt/context/docs.py +82 -0
  100. dvt/context/exceptions_jinja.py +179 -0
  101. dvt/context/macro_resolver.py +195 -0
  102. dvt/context/macros.py +171 -0
  103. dvt/context/manifest.py +73 -0
  104. dvt/context/providers.py +2198 -0
  105. dvt/context/query_header.py +14 -0
  106. dvt/context/secret.py +59 -0
  107. dvt/context/target.py +74 -0
  108. dvt/contracts/__init__.py +0 -0
  109. dvt/contracts/files.py +413 -0
  110. dvt/contracts/graph/__init__.py +0 -0
  111. dvt/contracts/graph/manifest.py +1904 -0
  112. dvt/contracts/graph/metrics.py +98 -0
  113. dvt/contracts/graph/model_config.py +71 -0
  114. dvt/contracts/graph/node_args.py +42 -0
  115. dvt/contracts/graph/nodes.py +1806 -0
  116. dvt/contracts/graph/semantic_manifest.py +233 -0
  117. dvt/contracts/graph/unparsed.py +812 -0
  118. dvt/contracts/project.py +417 -0
  119. dvt/contracts/results.py +53 -0
  120. dvt/contracts/selection.py +23 -0
  121. dvt/contracts/sql.py +86 -0
  122. dvt/contracts/state.py +69 -0
  123. dvt/contracts/util.py +46 -0
  124. dvt/deprecations.py +347 -0
  125. dvt/deps/__init__.py +0 -0
  126. dvt/deps/base.py +153 -0
  127. dvt/deps/git.py +196 -0
  128. dvt/deps/local.py +80 -0
  129. dvt/deps/registry.py +131 -0
  130. dvt/deps/resolver.py +149 -0
  131. dvt/deps/tarball.py +121 -0
  132. dvt/docs/source/_ext/dbt_click.py +118 -0
  133. dvt/docs/source/conf.py +32 -0
  134. dvt/env_vars.py +64 -0
  135. dvt/event_time/event_time.py +40 -0
  136. dvt/event_time/sample_window.py +60 -0
  137. dvt/events/__init__.py +16 -0
  138. dvt/events/base_types.py +37 -0
  139. dvt/events/core_types_pb2.py +2 -0
  140. dvt/events/logging.py +109 -0
  141. dvt/events/types.py +2534 -0
  142. dvt/exceptions.py +1487 -0
  143. dvt/flags.py +89 -0
  144. dvt/graph/__init__.py +11 -0
  145. dvt/graph/cli.py +248 -0
  146. dvt/graph/graph.py +172 -0
  147. dvt/graph/queue.py +213 -0
  148. dvt/graph/selector.py +375 -0
  149. dvt/graph/selector_methods.py +976 -0
  150. dvt/graph/selector_spec.py +223 -0
  151. dvt/graph/thread_pool.py +18 -0
  152. dvt/hooks.py +21 -0
  153. dvt/include/README.md +49 -0
  154. dvt/include/__init__.py +3 -0
  155. dvt/include/global_project.py +4 -0
  156. dvt/include/starter_project/.gitignore +4 -0
  157. dvt/include/starter_project/README.md +15 -0
  158. dvt/include/starter_project/__init__.py +3 -0
  159. dvt/include/starter_project/analyses/.gitkeep +0 -0
  160. dvt/include/starter_project/dvt_project.yml +36 -0
  161. dvt/include/starter_project/macros/.gitkeep +0 -0
  162. dvt/include/starter_project/models/example/my_first_dbt_model.sql +27 -0
  163. dvt/include/starter_project/models/example/my_second_dbt_model.sql +6 -0
  164. dvt/include/starter_project/models/example/schema.yml +21 -0
  165. dvt/include/starter_project/seeds/.gitkeep +0 -0
  166. dvt/include/starter_project/snapshots/.gitkeep +0 -0
  167. dvt/include/starter_project/tests/.gitkeep +0 -0
  168. dvt/internal_deprecations.py +27 -0
  169. dvt/jsonschemas/__init__.py +3 -0
  170. dvt/jsonschemas/jsonschemas.py +309 -0
  171. dvt/jsonschemas/project/0.0.110.json +4717 -0
  172. dvt/jsonschemas/project/0.0.85.json +2015 -0
  173. dvt/jsonschemas/resources/0.0.110.json +2636 -0
  174. dvt/jsonschemas/resources/0.0.85.json +2536 -0
  175. dvt/jsonschemas/resources/latest.json +6773 -0
  176. dvt/links.py +4 -0
  177. dvt/materializations/__init__.py +0 -0
  178. dvt/materializations/incremental/__init__.py +0 -0
  179. dvt/materializations/incremental/microbatch.py +235 -0
  180. dvt/mp_context.py +8 -0
  181. dvt/node_types.py +37 -0
  182. dvt/parser/__init__.py +23 -0
  183. dvt/parser/analysis.py +21 -0
  184. dvt/parser/base.py +549 -0
  185. dvt/parser/common.py +267 -0
  186. dvt/parser/docs.py +52 -0
  187. dvt/parser/fixtures.py +51 -0
  188. dvt/parser/functions.py +30 -0
  189. dvt/parser/generic_test.py +100 -0
  190. dvt/parser/generic_test_builders.py +334 -0
  191. dvt/parser/hooks.py +119 -0
  192. dvt/parser/macros.py +137 -0
  193. dvt/parser/manifest.py +2204 -0
  194. dvt/parser/models.py +574 -0
  195. dvt/parser/partial.py +1179 -0
  196. dvt/parser/read_files.py +445 -0
  197. dvt/parser/schema_generic_tests.py +423 -0
  198. dvt/parser/schema_renderer.py +111 -0
  199. dvt/parser/schema_yaml_readers.py +936 -0
  200. dvt/parser/schemas.py +1467 -0
  201. dvt/parser/search.py +149 -0
  202. dvt/parser/seeds.py +28 -0
  203. dvt/parser/singular_test.py +20 -0
  204. dvt/parser/snapshots.py +44 -0
  205. dvt/parser/sources.py +557 -0
  206. dvt/parser/sql.py +63 -0
  207. dvt/parser/unit_tests.py +622 -0
  208. dvt/plugins/__init__.py +20 -0
  209. dvt/plugins/contracts.py +10 -0
  210. dvt/plugins/exceptions.py +2 -0
  211. dvt/plugins/manager.py +164 -0
  212. dvt/plugins/manifest.py +21 -0
  213. dvt/profiler.py +20 -0
  214. dvt/py.typed +1 -0
  215. dvt/runners/__init__.py +2 -0
  216. dvt/runners/exposure_runner.py +7 -0
  217. dvt/runners/no_op_runner.py +46 -0
  218. dvt/runners/saved_query_runner.py +7 -0
  219. dvt/selected_resources.py +8 -0
  220. dvt/task/__init__.py +0 -0
  221. dvt/task/base.py +504 -0
  222. dvt/task/build.py +197 -0
  223. dvt/task/clean.py +57 -0
  224. dvt/task/clone.py +162 -0
  225. dvt/task/compile.py +151 -0
  226. dvt/task/compute.py +366 -0
  227. dvt/task/debug.py +650 -0
  228. dvt/task/deps.py +280 -0
  229. dvt/task/docs/__init__.py +3 -0
  230. dvt/task/docs/generate.py +408 -0
  231. dvt/task/docs/index.html +250 -0
  232. dvt/task/docs/serve.py +28 -0
  233. dvt/task/freshness.py +323 -0
  234. dvt/task/function.py +122 -0
  235. dvt/task/group_lookup.py +46 -0
  236. dvt/task/init.py +374 -0
  237. dvt/task/list.py +237 -0
  238. dvt/task/printer.py +176 -0
  239. dvt/task/profiles.py +256 -0
  240. dvt/task/retry.py +175 -0
  241. dvt/task/run.py +1146 -0
  242. dvt/task/run_operation.py +142 -0
  243. dvt/task/runnable.py +802 -0
  244. dvt/task/seed.py +104 -0
  245. dvt/task/show.py +150 -0
  246. dvt/task/snapshot.py +57 -0
  247. dvt/task/sql.py +111 -0
  248. dvt/task/test.py +464 -0
  249. dvt/tests/fixtures/__init__.py +1 -0
  250. dvt/tests/fixtures/project.py +620 -0
  251. dvt/tests/util.py +651 -0
  252. dvt/tracking.py +529 -0
  253. dvt/utils/__init__.py +3 -0
  254. dvt/utils/artifact_upload.py +151 -0
  255. dvt/utils/utils.py +408 -0
  256. dvt/version.py +249 -0
  257. dvt_core-1.11.0b4.dist-info/METADATA +252 -0
  258. dvt_core-1.11.0b4.dist-info/RECORD +261 -0
  259. dvt_core-1.11.0b4.dist-info/WHEEL +5 -0
  260. dvt_core-1.11.0b4.dist-info/entry_points.txt +2 -0
  261. dvt_core-1.11.0b4.dist-info/top_level.txt +1 -0
dvt/cli/params.py ADDED
@@ -0,0 +1,803 @@
1
+ from pathlib import Path
2
+ from typing import Any, Callable, List
3
+
4
+ import click
5
+ from dvt.cli.option_types import (
6
+ YAML,
7
+ ChoiceTuple,
8
+ Package,
9
+ SampleType,
10
+ WarnErrorOptionsType,
11
+ )
12
+ from dvt.cli.options import MultiOption
13
+ from dvt.cli.resolvers import default_profiles_dir, default_project_dir
14
+ from dvt.version import get_version_information
15
+
16
+ # --- shared option specs --- #
17
+ model_decls = ("-m", "--models", "--model")
18
+ select_decls = ("-s", "--select")
19
+ select_attrs = {
20
+ "envvar": None,
21
+ "help": "Specify the nodes to include.",
22
+ "cls": MultiOption,
23
+ "multiple": True,
24
+ "type": tuple,
25
+ }
26
+
27
+ # Record of env vars associated with options
28
+ KNOWN_ENV_VARS: List[str] = []
29
+
30
+
31
+ def _create_option_and_track_env_var(
32
+ *args: Any, **kwargs: Any
33
+ ) -> Callable[[click.decorators.FC], click.decorators.FC]:
34
+ global KNOWN_ENV_VARS
35
+
36
+ envvar = kwargs.get("envvar", None)
37
+ if isinstance(envvar, str):
38
+ KNOWN_ENV_VARS.append(envvar)
39
+
40
+ return click.option(*args, **kwargs)
41
+
42
+
43
+ # --- The actual option definitions --- #
44
+ add_package = _create_option_and_track_env_var(
45
+ "--add-package",
46
+ help="Add a package to current package spec, specify it as package-name@version. Change the source with --source flag.",
47
+ envvar=None,
48
+ type=Package(),
49
+ )
50
+
51
+ args = _create_option_and_track_env_var(
52
+ "--args",
53
+ envvar=None,
54
+ help="Supply arguments to the macro. This dictionary will be mapped to the keyword arguments defined in the selected macro. This argument should be a YAML string, eg. '{my_variable: my_value}'",
55
+ type=YAML(),
56
+ )
57
+
58
+ browser = _create_option_and_track_env_var(
59
+ "--browser/--no-browser",
60
+ envvar=None,
61
+ help="Whether or not to open a local web browser after starting the server",
62
+ default=True,
63
+ )
64
+
65
+ cache_selected_only = _create_option_and_track_env_var(
66
+ "--cache-selected-only/--no-cache-selected-only",
67
+ envvar="DBT_CACHE_SELECTED_ONLY",
68
+ help="At start of run, populate relational cache only for schemas containing selected nodes, or for all schemas of interest.",
69
+ )
70
+
71
+ clean_project_files_only = _create_option_and_track_env_var(
72
+ "--clean-project-files-only / --no-clean-project-files-only",
73
+ envvar="DBT_CLEAN_PROJECT_FILES_ONLY",
74
+ help="If disabled, dbt clean will delete all paths specified in clean-paths, even if they're outside the dbt project.",
75
+ default=True,
76
+ )
77
+
78
+ compile_docs = _create_option_and_track_env_var(
79
+ "--compile/--no-compile",
80
+ envvar=None,
81
+ help="Whether or not to run 'dbt compile' as part of docs generation",
82
+ default=True,
83
+ )
84
+
85
+ compile_inject_ephemeral_ctes = _create_option_and_track_env_var(
86
+ "--inject-ephemeral-ctes/--no-inject-ephemeral-ctes",
87
+ envvar=None,
88
+ help="Internal flag controlling injection of referenced ephemeral models' CTEs during `compile`.",
89
+ hidden=True,
90
+ default=True,
91
+ )
92
+
93
+ config_dir = _create_option_and_track_env_var(
94
+ "--config-dir",
95
+ envvar=None,
96
+ help="Print a system-specific command to access the directory that the current dbt project is searching for a profiles.yml. Then, exit. This flag renders other debug step flags no-ops.",
97
+ is_flag=True,
98
+ )
99
+
100
+ debug = _create_option_and_track_env_var(
101
+ "--debug/--no-debug",
102
+ "-d/ ",
103
+ envvar="DBT_DEBUG",
104
+ help="Display debug logging during dbt execution. Useful for debugging and making bug reports.",
105
+ )
106
+
107
+ debug_connection = _create_option_and_track_env_var(
108
+ "--connection",
109
+ envvar=None,
110
+ help="Test the connection to the target database independent of dependency checks.",
111
+ is_flag=True,
112
+ )
113
+
114
+ all_profiles = _create_option_and_track_env_var(
115
+ "--all-profiles",
116
+ envvar=None,
117
+ help="DVT extension: Test all configured profiles in profiles.yml, not just the project profile.",
118
+ is_flag=True,
119
+ )
120
+
121
+ # flag was previously named DEFER_MODE
122
+ defer = _create_option_and_track_env_var(
123
+ "--defer/--no-defer",
124
+ envvar="DBT_DEFER",
125
+ help="If set, resolve unselected nodes by deferring to the manifest within the --state directory.",
126
+ )
127
+
128
+ defer_state = _create_option_and_track_env_var(
129
+ "--defer-state",
130
+ envvar="DBT_DEFER_STATE",
131
+ help="Override the state directory for deferral only.",
132
+ type=click.Path(
133
+ dir_okay=True,
134
+ file_okay=False,
135
+ readable=True,
136
+ resolve_path=False,
137
+ path_type=Path,
138
+ ),
139
+ )
140
+
141
+ deprecated_defer = _create_option_and_track_env_var(
142
+ "--deprecated-defer",
143
+ envvar="DBT_DEFER_TO_STATE",
144
+ help="Internal flag for deprecating old env var.",
145
+ default=False,
146
+ hidden=True,
147
+ )
148
+
149
+ deprecated_favor_state = _create_option_and_track_env_var(
150
+ "--deprecated-favor-state",
151
+ envvar="DBT_FAVOR_STATE_MODE",
152
+ help="Internal flag for deprecating old env var.",
153
+ )
154
+
155
+ # Renamed to --export-saved-queries
156
+ deprecated_include_saved_query = _create_option_and_track_env_var(
157
+ "--include-saved-query/--no-include-saved-query",
158
+ envvar="DBT_INCLUDE_SAVED_QUERY",
159
+ help="Include saved queries in the list of resources to be selected for build command",
160
+ is_flag=True,
161
+ hidden=True,
162
+ )
163
+
164
+ deprecated_print = _create_option_and_track_env_var(
165
+ "--deprecated-print/--deprecated-no-print",
166
+ envvar="DBT_NO_PRINT",
167
+ help="Internal flag for deprecating old env var.",
168
+ default=True,
169
+ hidden=True,
170
+ callback=lambda ctx, param, value: not value,
171
+ )
172
+
173
+ deprecated_state = _create_option_and_track_env_var(
174
+ "--deprecated-state",
175
+ envvar="DBT_ARTIFACT_STATE_PATH",
176
+ help="Internal flag for deprecating old env var.",
177
+ hidden=True,
178
+ type=click.Path(
179
+ dir_okay=True,
180
+ file_okay=False,
181
+ readable=True,
182
+ resolve_path=True,
183
+ path_type=Path,
184
+ ),
185
+ )
186
+
187
+ empty = _create_option_and_track_env_var(
188
+ "--empty/--no-empty",
189
+ envvar="DBT_EMPTY",
190
+ help="If specified, limit input refs and sources to zero rows.",
191
+ is_flag=True,
192
+ )
193
+
194
+ empty_catalog = _create_option_and_track_env_var(
195
+ "--empty-catalog",
196
+ help="If specified, generate empty catalog.json file during the `dbt docs generate` command.",
197
+ default=False,
198
+ is_flag=True,
199
+ )
200
+
201
+ event_time_end = _create_option_and_track_env_var(
202
+ "--event-time-end",
203
+ envvar="DBT_EVENT_TIME_END",
204
+ help="If specified, the end datetime dbt uses to filter microbatch model inputs (exclusive).",
205
+ type=click.DateTime(),
206
+ default=None,
207
+ )
208
+
209
+ event_time_start = _create_option_and_track_env_var(
210
+ "--event-time-start",
211
+ envvar="DBT_EVENT_TIME_START",
212
+ help="If specified, the start datetime dbt uses to filter microbatch model inputs (inclusive).",
213
+ type=click.DateTime(),
214
+ default=None,
215
+ )
216
+
217
+ exclude = _create_option_and_track_env_var(
218
+ "--exclude",
219
+ envvar=None,
220
+ type=tuple,
221
+ cls=MultiOption,
222
+ multiple=True,
223
+ help="Specify the nodes to exclude.",
224
+ )
225
+
226
+ exclude_resource_type = _create_option_and_track_env_var(
227
+ "--exclude-resource-types",
228
+ "--exclude-resource-type",
229
+ envvar="DBT_EXCLUDE_RESOURCE_TYPES",
230
+ help="Specify the types of resources that dbt will exclude",
231
+ type=ChoiceTuple(
232
+ [
233
+ "metric",
234
+ "semantic_model",
235
+ "saved_query",
236
+ "source",
237
+ "analysis",
238
+ "model",
239
+ "test",
240
+ "unit_test",
241
+ "exposure",
242
+ "snapshot",
243
+ "seed",
244
+ "default",
245
+ ],
246
+ case_sensitive=False,
247
+ ),
248
+ cls=MultiOption,
249
+ multiple=True,
250
+ default=(),
251
+ )
252
+
253
+ export_saved_queries = _create_option_and_track_env_var(
254
+ "--export-saved-queries/--no-export-saved-queries",
255
+ envvar="DBT_EXPORT_SAVED_QUERIES",
256
+ help="Export saved queries within the 'build' command, otherwise no-op",
257
+ is_flag=True,
258
+ hidden=True,
259
+ )
260
+
261
+ fail_fast = _create_option_and_track_env_var(
262
+ "--fail-fast/--no-fail-fast",
263
+ "-x/ ",
264
+ envvar="DBT_FAIL_FAST",
265
+ help="Stop execution on first failure.",
266
+ )
267
+
268
+ favor_state = _create_option_and_track_env_var(
269
+ "--favor-state/--no-favor-state",
270
+ envvar="DBT_FAVOR_STATE",
271
+ help="If set, defer to the argument provided to the state flag for resolving unselected nodes, even if the node(s) exist as a database object in the current environment.",
272
+ )
273
+
274
+ full_refresh = _create_option_and_track_env_var(
275
+ "--full-refresh",
276
+ "-f",
277
+ envvar="DBT_FULL_REFRESH",
278
+ help="If specified, dbt will drop incremental models and fully-recalculate the incremental table from the model definition.",
279
+ is_flag=True,
280
+ )
281
+
282
+ host = _create_option_and_track_env_var(
283
+ "--host",
284
+ envvar="DBT_HOST",
285
+ help="host to serve dbt docs on",
286
+ type=click.STRING,
287
+ default="127.0.0.1",
288
+ )
289
+
290
+ indirect_selection = _create_option_and_track_env_var(
291
+ "--indirect-selection",
292
+ envvar="DBT_INDIRECT_SELECTION",
293
+ help="Choose which tests to select that are adjacent to selected resources. Eager is most inclusive, cautious is most exclusive, and buildable is in between. Empty includes no tests at all.",
294
+ type=click.Choice(["eager", "cautious", "buildable", "empty"], case_sensitive=False),
295
+ default="eager",
296
+ )
297
+
298
+ inline = _create_option_and_track_env_var(
299
+ "--inline",
300
+ envvar=None,
301
+ help="Pass SQL inline to dbt compile and show",
302
+ )
303
+
304
+ inline_direct = _create_option_and_track_env_var(
305
+ "--inline-direct",
306
+ envvar=None,
307
+ help="Internal flag to pass SQL inline to dbt show. Do not load the entire project or apply templating.",
308
+ hidden=True,
309
+ )
310
+
311
+ introspect = _create_option_and_track_env_var(
312
+ "--introspect/--no-introspect",
313
+ envvar="DBT_INTROSPECT",
314
+ help="Whether to scaffold introspective queries as part of compilation",
315
+ default=True,
316
+ )
317
+
318
+ lock = _create_option_and_track_env_var(
319
+ "--lock",
320
+ envvar=None,
321
+ help="Generate the package-lock.yml file without install the packages.",
322
+ is_flag=True,
323
+ )
324
+
325
+ log_cache_events = _create_option_and_track_env_var(
326
+ "--log-cache-events/--no-log-cache-events",
327
+ help="Enable verbose logging for relational cache events to help when debugging.",
328
+ envvar="DBT_LOG_CACHE_EVENTS",
329
+ )
330
+
331
+ log_format = _create_option_and_track_env_var(
332
+ "--log-format",
333
+ envvar="DBT_LOG_FORMAT",
334
+ help="Specify the format of logging to the console and the log file. Use --log-format-file to configure the format for the log file differently than the console.",
335
+ type=click.Choice(["text", "debug", "json", "default"], case_sensitive=False),
336
+ default="default",
337
+ )
338
+
339
+ log_format_file = _create_option_and_track_env_var(
340
+ "--log-format-file",
341
+ envvar="DBT_LOG_FORMAT_FILE",
342
+ help="Specify the format of logging to the log file by overriding the default value and the general --log-format setting.",
343
+ type=click.Choice(["text", "debug", "json", "default"], case_sensitive=False),
344
+ default="debug",
345
+ )
346
+
347
+ log_level = _create_option_and_track_env_var(
348
+ "--log-level",
349
+ envvar="DBT_LOG_LEVEL",
350
+ help="Specify the minimum severity of events that are logged to the console and the log file. Use --log-level-file to configure the severity for the log file differently than the console.",
351
+ type=click.Choice(["debug", "info", "warn", "error", "none"], case_sensitive=False),
352
+ default="info",
353
+ )
354
+
355
+ log_level_file = _create_option_and_track_env_var(
356
+ "--log-level-file",
357
+ envvar="DBT_LOG_LEVEL_FILE",
358
+ help="Specify the minimum severity of events that are logged to the log file by overriding the default value and the general --log-level setting.",
359
+ type=click.Choice(["debug", "info", "warn", "error", "none"], case_sensitive=False),
360
+ default="debug",
361
+ )
362
+
363
+ log_file_max_bytes = _create_option_and_track_env_var(
364
+ "--log-file-max-bytes",
365
+ envvar="DBT_LOG_FILE_MAX_BYTES",
366
+ help="Configure the max file size in bytes for a single dbt.log file, before rolling over. 0 means no limit.",
367
+ default=10 * 1024 * 1024, # 10mb
368
+ type=click.INT,
369
+ hidden=True,
370
+ )
371
+
372
+ log_path = _create_option_and_track_env_var(
373
+ "--log-path",
374
+ envvar="DBT_LOG_PATH",
375
+ help="Configure the 'log-path'. Only applies this setting for the current run. Overrides the 'DBT_LOG_PATH' if it is set.",
376
+ default=None,
377
+ type=click.Path(resolve_path=True, path_type=Path),
378
+ )
379
+
380
+ macro_debugging = _create_option_and_track_env_var(
381
+ "--macro-debugging/--no-macro-debugging",
382
+ envvar="DBT_MACRO_DEBUGGING",
383
+ hidden=True,
384
+ )
385
+
386
+ models = _create_option_and_track_env_var(*model_decls, **select_attrs) # type: ignore[arg-type]
387
+
388
+ # This less standard usage of --output where output_path below is more standard
389
+ output = _create_option_and_track_env_var(
390
+ "--output",
391
+ envvar=None,
392
+ help="Specify the output format: either JSON or a newline-delimited list of selectors, paths, or names",
393
+ type=click.Choice(["json", "name", "path", "selector"], case_sensitive=False),
394
+ default="selector",
395
+ )
396
+
397
+ output_keys = _create_option_and_track_env_var(
398
+ "--output-keys",
399
+ envvar=None,
400
+ help=(
401
+ "Space-delimited listing of node properties to include as custom keys for JSON output. "
402
+ "Supports nested keys using dot notation "
403
+ "(e.g. `--output json --output-keys name config.materialized resource_type`)"
404
+ ),
405
+ type=tuple,
406
+ cls=MultiOption,
407
+ multiple=True,
408
+ default=[],
409
+ )
410
+
411
+ output_path = _create_option_and_track_env_var(
412
+ "--output",
413
+ "-o",
414
+ envvar=None,
415
+ help="Specify the output path for the JSON report. By default, outputs to 'target/sources.json'",
416
+ type=click.Path(file_okay=True, dir_okay=False, writable=True),
417
+ default=None,
418
+ )
419
+
420
+ partial_parse = _create_option_and_track_env_var(
421
+ "--partial-parse/--no-partial-parse",
422
+ envvar="DBT_PARTIAL_PARSE",
423
+ help="Allow for partial parsing by looking for and writing to a pickle file in the target directory. This overrides the user configuration file.",
424
+ default=True,
425
+ )
426
+
427
+ partial_parse_file_diff = _create_option_and_track_env_var(
428
+ "--partial-parse-file-diff/--no-partial-parse-file-diff",
429
+ envvar="DBT_PARTIAL_PARSE_FILE_DIFF",
430
+ help="Internal flag for whether to compute a file diff during partial parsing.",
431
+ hidden=True,
432
+ default=True,
433
+ )
434
+
435
+ partial_parse_file_path = _create_option_and_track_env_var(
436
+ "--partial-parse-file-path",
437
+ envvar="DBT_PARTIAL_PARSE_FILE_PATH",
438
+ help="Internal flag for path to partial_parse.manifest file.",
439
+ default=None,
440
+ hidden=True,
441
+ type=click.Path(exists=True, dir_okay=False, resolve_path=True),
442
+ )
443
+
444
+ print = _create_option_and_track_env_var(
445
+ "--print/--no-print",
446
+ envvar="DBT_PRINT",
447
+ help="Output all {{ print() }} macro calls.",
448
+ default=True,
449
+ )
450
+
451
+ populate_cache = _create_option_and_track_env_var(
452
+ "--populate-cache/--no-populate-cache",
453
+ envvar="DBT_POPULATE_CACHE",
454
+ help="At start of run, use `show` or `information_schema` queries to populate a relational cache, which can speed up subsequent materializations.",
455
+ default=True,
456
+ )
457
+
458
+ port = _create_option_and_track_env_var(
459
+ "--port",
460
+ envvar=None,
461
+ help="Specify the port number for the docs server",
462
+ default=8080,
463
+ type=click.INT,
464
+ )
465
+
466
+ printer_width = _create_option_and_track_env_var(
467
+ "--printer-width",
468
+ envvar="DBT_PRINTER_WIDTH",
469
+ help="Sets the width of terminal output",
470
+ type=click.INT,
471
+ default=80,
472
+ )
473
+
474
+ profile = _create_option_and_track_env_var(
475
+ "--profile",
476
+ envvar="DBT_PROFILE",
477
+ help="Which existing profile to load. Overrides setting in project file.",
478
+ )
479
+
480
+ profiles_dir = _create_option_and_track_env_var(
481
+ "--profiles-dir",
482
+ envvar="DBT_PROFILES_DIR",
483
+ help="Which directory to look in for the profiles.yml file. If not set, dbt will look in the current working directory first, then HOME/.dbt/",
484
+ default=default_profiles_dir,
485
+ type=click.Path(exists=True),
486
+ )
487
+
488
+ # `dbt debug` uses this because it implements custom behaviour for non-existent profiles.yml directories
489
+ # `dbt deps` does not load a profile at all
490
+ # `dbt init` will write profiles.yml if it doesn't yet exist
491
+ profiles_dir_exists_false = _create_option_and_track_env_var(
492
+ "--profiles-dir",
493
+ envvar="DBT_PROFILES_DIR",
494
+ help="Which directory to look in for the profiles.yml file. If not set, dbt will look in the current working directory first, then HOME/.dbt/",
495
+ default=default_profiles_dir,
496
+ type=click.Path(exists=False),
497
+ )
498
+
499
+ project_dir = _create_option_and_track_env_var(
500
+ "--project-dir",
501
+ envvar="DBT_PROJECT_DIR",
502
+ help="Which directory to look in for the dvt_project.yml file. Default is the current working directory and its parents.",
503
+ default=default_project_dir,
504
+ type=click.Path(exists=True),
505
+ )
506
+
507
+ quiet = _create_option_and_track_env_var(
508
+ "--quiet/--no-quiet",
509
+ "-q",
510
+ envvar="DBT_QUIET",
511
+ help="Suppress all non-error logging to stdout. Does not affect {{ print() }} macro calls.",
512
+ )
513
+
514
+ raw_select = _create_option_and_track_env_var(*select_decls, **select_attrs) # type: ignore[arg-type]
515
+
516
+ record_timing_info = _create_option_and_track_env_var(
517
+ "--record-timing-info",
518
+ "-r",
519
+ envvar=None,
520
+ help="When this option is passed, dbt will output low-level timing stats to the specified file. Example: `--record-timing-info output.profile`",
521
+ type=click.Path(exists=False),
522
+ )
523
+
524
+ resource_type = _create_option_and_track_env_var(
525
+ "--resource-types",
526
+ "--resource-type",
527
+ envvar="DBT_RESOURCE_TYPES",
528
+ help="Restricts the types of resources that dbt will include",
529
+ type=ChoiceTuple(
530
+ [
531
+ "metric",
532
+ "semantic_model",
533
+ "saved_query",
534
+ "source",
535
+ "analysis",
536
+ "function",
537
+ "model",
538
+ "test",
539
+ "unit_test",
540
+ "exposure",
541
+ "snapshot",
542
+ "seed",
543
+ "default",
544
+ "all",
545
+ ],
546
+ case_sensitive=False,
547
+ ),
548
+ cls=MultiOption,
549
+ multiple=True,
550
+ default=(),
551
+ )
552
+
553
+ sample = _create_option_and_track_env_var(
554
+ "--sample",
555
+ envvar="DBT_SAMPLE",
556
+ help="Run in sample mode with given SAMPLE_WINDOW spec, such that ref/source calls are sampled by the sample window.",
557
+ default=None,
558
+ type=SampleType(),
559
+ )
560
+
561
+ # `--select` and `--models` are analogous for most commands except `dbt list` for legacy reasons.
562
+ # Most CLI arguments should use the combined `select` option that aliases `--models` to `--select`.
563
+ # However, if you need to split out these separators (like `dbt ls`), use the `models` and `raw_select` options instead.
564
+ # See https://github.com/dbt-labs/dbt-core/pull/6774#issuecomment-1408476095 for more info.
565
+ select = _create_option_and_track_env_var(*select_decls, *model_decls, **select_attrs) # type: ignore[arg-type]
566
+
567
+ selector = _create_option_and_track_env_var(
568
+ "--selector",
569
+ envvar=None,
570
+ help="The selector name to use, as defined in selectors.yml",
571
+ )
572
+
573
+ send_anonymous_usage_stats = _create_option_and_track_env_var(
574
+ "--send-anonymous-usage-stats/--no-send-anonymous-usage-stats",
575
+ envvar="DBT_SEND_ANONYMOUS_USAGE_STATS",
576
+ help="Send anonymous usage stats to dbt Labs.",
577
+ default=True,
578
+ )
579
+
580
+ show = _create_option_and_track_env_var(
581
+ "--show",
582
+ envvar=None,
583
+ help="Show a sample of the loaded data in the terminal",
584
+ is_flag=True,
585
+ )
586
+
587
+ show_limit = _create_option_and_track_env_var(
588
+ "--limit",
589
+ envvar=None,
590
+ help="Limit the number of results returned by dbt show",
591
+ type=click.INT,
592
+ default=5,
593
+ )
594
+
595
+ show_output_format = _create_option_and_track_env_var(
596
+ "--output",
597
+ envvar=None,
598
+ help="Output format for dbt compile and dbt show",
599
+ type=click.Choice(["json", "text"], case_sensitive=False),
600
+ default="text",
601
+ )
602
+
603
+ show_resource_report = _create_option_and_track_env_var(
604
+ "--show-resource-report/--no-show-resource-report",
605
+ default=False,
606
+ envvar="DBT_SHOW_RESOURCE_REPORT",
607
+ hidden=True,
608
+ )
609
+
610
+ # TODO: The env var is a correction!
611
+ # The original env var was `DBT_TEST_SINGLE_THREADED`.
612
+ # This broke the existing naming convention.
613
+ # This will need to be communicated as a change to the community!
614
+ #
615
+ # N.B. This flag is only used for testing, hence it's hidden from help text.
616
+ single_threaded = _create_option_and_track_env_var(
617
+ "--single-threaded/--no-single-threaded",
618
+ envvar="DBT_SINGLE_THREADED",
619
+ default=False,
620
+ hidden=True,
621
+ )
622
+
623
+ show_all_deprecations = _create_option_and_track_env_var(
624
+ "--show-all-deprecations/--no-show-all-deprecations",
625
+ envvar=None,
626
+ help="By default, each type of a deprecation warning is only shown once. Use this flag to show all deprecation warning instances.",
627
+ is_flag=True,
628
+ default=False,
629
+ )
630
+
631
+ skip_profile_setup = _create_option_and_track_env_var(
632
+ "--skip-profile-setup",
633
+ "-s",
634
+ envvar=None,
635
+ help="Skip interactive profile setup.",
636
+ is_flag=True,
637
+ )
638
+
639
+ source = _create_option_and_track_env_var(
640
+ "--source",
641
+ envvar=None,
642
+ help="Source to download page from, must be one of hub, git, or local. Defaults to hub.",
643
+ type=click.Choice(["hub", "git", "local"], case_sensitive=True),
644
+ default="hub",
645
+ )
646
+
647
+ state = _create_option_and_track_env_var(
648
+ "--state",
649
+ envvar="DBT_STATE",
650
+ help="Unless overridden, use this state directory for both state comparison and deferral.",
651
+ type=click.Path(
652
+ dir_okay=True,
653
+ file_okay=False,
654
+ readable=True,
655
+ resolve_path=False,
656
+ path_type=Path,
657
+ ),
658
+ )
659
+
660
+ static = _create_option_and_track_env_var(
661
+ "--static",
662
+ help="Generate an additional static_index.html with manifest and catalog built-in.",
663
+ default=False,
664
+ is_flag=True,
665
+ )
666
+
667
+ static_parser = _create_option_and_track_env_var(
668
+ "--static-parser/--no-static-parser",
669
+ envvar="DBT_STATIC_PARSER",
670
+ help="Use the static parser.",
671
+ default=True,
672
+ )
673
+
674
+ store_failures = _create_option_and_track_env_var(
675
+ "--store-failures",
676
+ envvar="DBT_STORE_FAILURES",
677
+ help="Store test results (failing rows) in the database",
678
+ is_flag=True,
679
+ )
680
+
681
+ target = _create_option_and_track_env_var(
682
+ "--target",
683
+ "-t",
684
+ envvar="DBT_TARGET",
685
+ help="Which target to load for the given profile",
686
+ )
687
+
688
+ target_path = _create_option_and_track_env_var(
689
+ "--target-path",
690
+ envvar="DBT_TARGET_PATH",
691
+ help="Configure the 'target-path'. Only applies this setting for the current run. Overrides the 'DBT_TARGET_PATH' if it is set.",
692
+ type=click.Path(),
693
+ )
694
+
695
+ threads = _create_option_and_track_env_var(
696
+ "--threads",
697
+ envvar=None,
698
+ help="Specify number of threads to use while executing models. Overrides settings in profiles.yml.",
699
+ default=None,
700
+ type=click.INT,
701
+ )
702
+
703
+ upgrade = _create_option_and_track_env_var(
704
+ "--upgrade",
705
+ envvar=None,
706
+ help="Upgrade packages to the latest version.",
707
+ is_flag=True,
708
+ )
709
+
710
+ use_colors = _create_option_and_track_env_var(
711
+ "--use-colors/--no-use-colors",
712
+ envvar="DBT_USE_COLORS",
713
+ help="Specify whether log output is colorized in the console and the log file. Use --use-colors-file/--no-use-colors-file to colorize the log file differently than the console.",
714
+ default=True,
715
+ )
716
+
717
+ use_colors_file = _create_option_and_track_env_var(
718
+ "--use-colors-file/--no-use-colors-file",
719
+ envvar="DBT_USE_COLORS_FILE",
720
+ help="Specify whether log file output is colorized by overriding the default value and the general --use-colors/--no-use-colors setting.",
721
+ default=True,
722
+ )
723
+
724
+ use_experimental_parser = _create_option_and_track_env_var(
725
+ "--use-experimental-parser/--no-use-experimental-parser",
726
+ envvar="DBT_USE_EXPERIMENTAL_PARSER",
727
+ help="Enable experimental parsing features.",
728
+ )
729
+
730
+ use_fast_test_edges = _create_option_and_track_env_var(
731
+ "--use-fast-test-edges/--no-use-fast-test-edges",
732
+ envvar="DBT_USE_FAST_TEST_EDGES",
733
+ default=False,
734
+ hidden=True,
735
+ )
736
+
737
+ vars = _create_option_and_track_env_var(
738
+ "--vars",
739
+ envvar=None,
740
+ help="Supply variables to the project. This argument overrides variables defined in your project file. This argument should be a YAML string, eg. '{my_variable: my_value}'",
741
+ type=YAML(),
742
+ default="{}",
743
+ )
744
+
745
+
746
+ # TODO: when legacy flags are deprecated use
747
+ # click.version_option instead of a callback
748
+ def _version_callback(ctx, _param, value):
749
+ if not value or ctx.resilient_parsing:
750
+ return
751
+ click.echo(get_version_information())
752
+ ctx.exit()
753
+
754
+
755
+ version = _create_option_and_track_env_var(
756
+ "--version",
757
+ "-V",
758
+ "-v",
759
+ callback=_version_callback,
760
+ envvar=None,
761
+ expose_value=False,
762
+ help="Show version information and exit",
763
+ is_eager=True,
764
+ is_flag=True,
765
+ )
766
+
767
+ version_check = _create_option_and_track_env_var(
768
+ "--version-check/--no-version-check",
769
+ envvar="DBT_VERSION_CHECK",
770
+ help="If set, ensure the installed dbt version matches the require-dbt-version specified in the project file (if any). Otherwise, allow them to differ.",
771
+ default=True,
772
+ )
773
+
774
+ warn_error = _create_option_and_track_env_var(
775
+ "--warn-error",
776
+ envvar="DBT_WARN_ERROR",
777
+ help="If dbt would normally warn, instead raise an exception. Examples include --select that selects nothing, deprecations, configurations with no associated models, invalid test configurations, and missing sources/refs in tests.",
778
+ default=None,
779
+ is_flag=True,
780
+ )
781
+
782
+ warn_error_options = _create_option_and_track_env_var(
783
+ "--warn-error-options",
784
+ envvar="DBT_WARN_ERROR_OPTIONS",
785
+ default="{}",
786
+ help="""If dbt would normally warn, instead raise an exception based on error/warn configuration. Examples include --select that selects nothing, deprecations, configurations with no associated models, invalid test configurations,
787
+ and missing sources/refs in tests. This argument should be a YAML string, with keys 'error' or 'warn'. eg. '{"error": "all", "warn": ["NoNodesForSelectionCriteria"]}'""",
788
+ type=WarnErrorOptionsType(),
789
+ )
790
+
791
+ write_json = _create_option_and_track_env_var(
792
+ "--write-json/--no-write-json",
793
+ envvar="DBT_WRITE_JSON",
794
+ help="Whether or not to write the manifest.json and run_results.json files to the target directory",
795
+ default=True,
796
+ )
797
+
798
+ upload_artifacts = _create_option_and_track_env_var(
799
+ "--upload-to-artifacts-ingest-api/--no-upload-to-artifacts-ingest-api",
800
+ envvar="DBT_UPLOAD_TO_ARTIFACTS_INGEST_API",
801
+ help="Whether or not to upload the artifacts to the dbt Cloud API",
802
+ default=False,
803
+ )