sqlmesh 0.199.1.dev33__py3-none-any.whl → 0.199.1.dev35__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.
- sqlmesh/_version.py +2 -2
- sqlmesh/core/context.py +6 -4
- sqlmesh/core/macros.py +3 -3
- sqlmesh/core/model/definition.py +17 -8
- sqlmesh/core/node.py +1 -1
- sqlmesh/core/renderer.py +1 -1
- sqlmesh/core/snapshot/definition.py +1 -1
- sqlmesh/dbt/converter/convert.py +6 -0
- sqlmesh/lsp/reference.py +8 -0
- sqlmesh/magics.py +6 -4
- {sqlmesh-0.199.1.dev33.dist-info → sqlmesh-0.199.1.dev35.dist-info}/METADATA +1 -1
- {sqlmesh-0.199.1.dev33.dist-info → sqlmesh-0.199.1.dev35.dist-info}/RECORD +19 -21
- web/server/api/endpoints/models.py +3 -2
- web/server/models.py +2 -2
- web/server/settings.py +1 -1
- sqlmesh/engines/commands.py +0 -184
- sqlmesh/engines/spark/app.py +0 -114
- {sqlmesh-0.199.1.dev33.dist-info → sqlmesh-0.199.1.dev35.dist-info}/WHEEL +0 -0
- {sqlmesh-0.199.1.dev33.dist-info → sqlmesh-0.199.1.dev35.dist-info}/entry_points.txt +0 -0
- {sqlmesh-0.199.1.dev33.dist-info → sqlmesh-0.199.1.dev35.dist-info}/licenses/LICENSE +0 -0
- {sqlmesh-0.199.1.dev33.dist-info → sqlmesh-0.199.1.dev35.dist-info}/top_level.txt +0 -0
sqlmesh/_version.py
CHANGED
|
@@ -17,5 +17,5 @@ __version__: str
|
|
|
17
17
|
__version_tuple__: VERSION_TUPLE
|
|
18
18
|
version_tuple: VERSION_TUPLE
|
|
19
19
|
|
|
20
|
-
__version__ = version = '0.199.1.
|
|
21
|
-
__version_tuple__ = version_tuple = (0, 199, 1, '
|
|
20
|
+
__version__ = version = '0.199.1.dev35'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 199, 1, 'dev35')
|
sqlmesh/core/context.py
CHANGED
|
@@ -948,10 +948,12 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
948
948
|
|
|
949
949
|
def config_for_node(self, node: str | Model | Audit) -> Config:
|
|
950
950
|
if isinstance(node, str):
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
951
|
+
path = self.get_snapshot(node, raise_if_missing=True).node._path
|
|
952
|
+
else:
|
|
953
|
+
path = node._path
|
|
954
|
+
if path is None:
|
|
955
|
+
return self.config
|
|
956
|
+
return self.config_for_path(path)[0] # type: ignore
|
|
955
957
|
|
|
956
958
|
@property
|
|
957
959
|
def models(self) -> MappingProxyType[str, Model]:
|
sqlmesh/core/macros.py
CHANGED
|
@@ -171,7 +171,7 @@ class MacroEvaluator:
|
|
|
171
171
|
resolve_tables: t.Optional[t.Callable[[exp.Expression], exp.Expression]] = None,
|
|
172
172
|
snapshots: t.Optional[t.Dict[str, Snapshot]] = None,
|
|
173
173
|
default_catalog: t.Optional[str] = None,
|
|
174
|
-
path: Path =
|
|
174
|
+
path: t.Optional[Path] = None,
|
|
175
175
|
environment_naming_info: t.Optional[EnvironmentNamingInfo] = None,
|
|
176
176
|
model_fqn: t.Optional[str] = None,
|
|
177
177
|
):
|
|
@@ -1384,7 +1384,7 @@ for m in macro.get_registry().values():
|
|
|
1384
1384
|
def call_macro(
|
|
1385
1385
|
func: t.Callable,
|
|
1386
1386
|
dialect: DialectType,
|
|
1387
|
-
path: Path,
|
|
1387
|
+
path: t.Optional[Path],
|
|
1388
1388
|
provided_args: t.Tuple[t.Any, ...],
|
|
1389
1389
|
provided_kwargs: t.Dict[str, t.Any],
|
|
1390
1390
|
**optional_kwargs: t.Any,
|
|
@@ -1431,7 +1431,7 @@ def _coerce(
|
|
|
1431
1431
|
expr: t.Any,
|
|
1432
1432
|
typ: t.Any,
|
|
1433
1433
|
dialect: DialectType,
|
|
1434
|
-
path: Path,
|
|
1434
|
+
path: t.Optional[Path] = None,
|
|
1435
1435
|
strict: bool = False,
|
|
1436
1436
|
) -> t.Any:
|
|
1437
1437
|
"""Coerces the given expression to the specified type on a best-effort basis."""
|
sqlmesh/core/model/definition.py
CHANGED
|
@@ -1648,6 +1648,8 @@ class SeedModel(_Model):
|
|
|
1648
1648
|
def seed_path(self) -> Path:
|
|
1649
1649
|
seed_path = Path(self.kind.path)
|
|
1650
1650
|
if not seed_path.is_absolute():
|
|
1651
|
+
if self._path is None:
|
|
1652
|
+
raise SQLMeshError(f"Seed model '{self.name}' has no path")
|
|
1651
1653
|
return self._path.parent / seed_path
|
|
1652
1654
|
return seed_path
|
|
1653
1655
|
|
|
@@ -2022,7 +2024,7 @@ def load_sql_based_model(
|
|
|
2022
2024
|
expressions: t.List[exp.Expression],
|
|
2023
2025
|
*,
|
|
2024
2026
|
defaults: t.Optional[t.Dict[str, t.Any]] = None,
|
|
2025
|
-
path: Path =
|
|
2027
|
+
path: t.Optional[Path] = None,
|
|
2026
2028
|
module_path: Path = Path(),
|
|
2027
2029
|
time_column_format: str = c.DEFAULT_TIME_COLUMN_FORMAT,
|
|
2028
2030
|
macros: t.Optional[MacroRegistry] = None,
|
|
@@ -2173,6 +2175,8 @@ Learn more at https://sqlmesh.readthedocs.io/en/stable/concepts/models/overview
|
|
|
2173
2175
|
# The name of the model will be inferred from its path relative to `models/`, if it's not explicitly specified
|
|
2174
2176
|
name = meta_fields.pop("name", "")
|
|
2175
2177
|
if not name and infer_names:
|
|
2178
|
+
if path is None:
|
|
2179
|
+
raise ValueError(f"Model {name} must have a name")
|
|
2176
2180
|
name = get_model_name(path)
|
|
2177
2181
|
|
|
2178
2182
|
if not name:
|
|
@@ -2251,7 +2255,7 @@ def create_seed_model(
|
|
|
2251
2255
|
name: TableName,
|
|
2252
2256
|
seed_kind: SeedKind,
|
|
2253
2257
|
*,
|
|
2254
|
-
path: Path =
|
|
2258
|
+
path: t.Optional[Path] = None,
|
|
2255
2259
|
module_path: Path = Path(),
|
|
2256
2260
|
**kwargs: t.Any,
|
|
2257
2261
|
) -> Model:
|
|
@@ -2270,7 +2274,12 @@ def create_seed_model(
|
|
|
2270
2274
|
seed_path = module_path.joinpath(*subdirs)
|
|
2271
2275
|
seed_kind.path = str(seed_path)
|
|
2272
2276
|
elif not seed_path.is_absolute():
|
|
2273
|
-
|
|
2277
|
+
if path is None:
|
|
2278
|
+
seed_path = seed_path
|
|
2279
|
+
elif path.is_dir():
|
|
2280
|
+
seed_path = path / seed_path
|
|
2281
|
+
else:
|
|
2282
|
+
seed_path = path.parent / seed_path
|
|
2274
2283
|
|
|
2275
2284
|
seed = create_seed(seed_path)
|
|
2276
2285
|
|
|
@@ -2405,7 +2414,7 @@ def _create_model(
|
|
|
2405
2414
|
name: TableName,
|
|
2406
2415
|
*,
|
|
2407
2416
|
defaults: t.Optional[t.Dict[str, t.Any]] = None,
|
|
2408
|
-
path: Path =
|
|
2417
|
+
path: t.Optional[Path] = None,
|
|
2409
2418
|
time_column_format: str = c.DEFAULT_TIME_COLUMN_FORMAT,
|
|
2410
2419
|
jinja_macros: t.Optional[JinjaMacroRegistry] = None,
|
|
2411
2420
|
jinja_macro_references: t.Optional[t.Set[MacroReference]] = None,
|
|
@@ -2593,7 +2602,7 @@ INSERT_SEED_MACRO_CALL = d.parse_one("@INSERT_SEED()")
|
|
|
2593
2602
|
|
|
2594
2603
|
def _split_sql_model_statements(
|
|
2595
2604
|
expressions: t.List[exp.Expression],
|
|
2596
|
-
path: Path,
|
|
2605
|
+
path: t.Optional[Path],
|
|
2597
2606
|
dialect: t.Optional[str] = None,
|
|
2598
2607
|
) -> t.Tuple[
|
|
2599
2608
|
t.Optional[exp.Expression],
|
|
@@ -2714,7 +2723,7 @@ def _refs_to_sql(values: t.Any) -> exp.Expression:
|
|
|
2714
2723
|
def render_meta_fields(
|
|
2715
2724
|
fields: t.Dict[str, t.Any],
|
|
2716
2725
|
module_path: Path,
|
|
2717
|
-
path: Path,
|
|
2726
|
+
path: t.Optional[Path],
|
|
2718
2727
|
jinja_macros: t.Optional[JinjaMacroRegistry],
|
|
2719
2728
|
macros: t.Optional[MacroRegistry],
|
|
2720
2729
|
dialect: DialectType,
|
|
@@ -2801,7 +2810,7 @@ def render_meta_fields(
|
|
|
2801
2810
|
def render_model_defaults(
|
|
2802
2811
|
defaults: t.Dict[str, t.Any],
|
|
2803
2812
|
module_path: Path,
|
|
2804
|
-
path: Path,
|
|
2813
|
+
path: t.Optional[Path],
|
|
2805
2814
|
jinja_macros: t.Optional[JinjaMacroRegistry],
|
|
2806
2815
|
macros: t.Optional[MacroRegistry],
|
|
2807
2816
|
dialect: DialectType,
|
|
@@ -2851,7 +2860,7 @@ def parse_defaults_properties(
|
|
|
2851
2860
|
def render_expression(
|
|
2852
2861
|
expression: exp.Expression,
|
|
2853
2862
|
module_path: Path,
|
|
2854
|
-
path: Path,
|
|
2863
|
+
path: t.Optional[Path],
|
|
2855
2864
|
jinja_macros: t.Optional[JinjaMacroRegistry] = None,
|
|
2856
2865
|
macros: t.Optional[MacroRegistry] = None,
|
|
2857
2866
|
dialect: DialectType = None,
|
sqlmesh/core/node.py
CHANGED
|
@@ -199,7 +199,7 @@ class _Node(PydanticModel):
|
|
|
199
199
|
interval_unit_: t.Optional[IntervalUnit] = Field(alias="interval_unit", default=None)
|
|
200
200
|
tags: t.List[str] = []
|
|
201
201
|
stamp: t.Optional[str] = None
|
|
202
|
-
_path: Path =
|
|
202
|
+
_path: t.Optional[Path] = None
|
|
203
203
|
_data_hash: t.Optional[str] = None
|
|
204
204
|
_metadata_hash: t.Optional[str] = None
|
|
205
205
|
|
sqlmesh/core/renderer.py
CHANGED
|
@@ -43,7 +43,7 @@ class BaseExpressionRenderer:
|
|
|
43
43
|
expression: exp.Expression,
|
|
44
44
|
dialect: DialectType,
|
|
45
45
|
macro_definitions: t.List[d.MacroDef],
|
|
46
|
-
path: Path =
|
|
46
|
+
path: t.Optional[Path] = None,
|
|
47
47
|
jinja_macro_registry: t.Optional[JinjaMacroRegistry] = None,
|
|
48
48
|
python_env: t.Optional[t.Dict[str, Executable]] = None,
|
|
49
49
|
only_execution_time: bool = False,
|
|
@@ -2198,7 +2198,7 @@ def check_ready_intervals(
|
|
|
2198
2198
|
context: ExecutionContext,
|
|
2199
2199
|
python_env: t.Dict[str, Executable],
|
|
2200
2200
|
dialect: DialectType = None,
|
|
2201
|
-
path: Path =
|
|
2201
|
+
path: t.Optional[Path] = None,
|
|
2202
2202
|
kwargs: t.Optional[t.Dict] = None,
|
|
2203
2203
|
) -> Intervals:
|
|
2204
2204
|
checked_intervals: Intervals = []
|
sqlmesh/dbt/converter/convert.py
CHANGED
|
@@ -207,6 +207,8 @@ def _convert_models(
|
|
|
207
207
|
|
|
208
208
|
if model.kind.is_seed:
|
|
209
209
|
# this will produce the original seed file, eg "items.csv"
|
|
210
|
+
if model._path is None:
|
|
211
|
+
raise ValueError(f"Unhandled model path for model {model_name}")
|
|
210
212
|
seed_filename = model._path.relative_to(input_paths.seeds)
|
|
211
213
|
|
|
212
214
|
# seed definition - rename "items.csv" -> "items.sql"
|
|
@@ -219,6 +221,8 @@ def _convert_models(
|
|
|
219
221
|
assert isinstance(model.kind, SeedKind)
|
|
220
222
|
model.kind.path = str(Path("../seeds", seed_filename))
|
|
221
223
|
else:
|
|
224
|
+
if model._path is None:
|
|
225
|
+
raise ValueError(f"Unhandled model path for model {model_name}")
|
|
222
226
|
if input_paths.models in model._path.parents:
|
|
223
227
|
model_filename = model._path.relative_to(input_paths.models)
|
|
224
228
|
elif input_paths.snapshots in model._path.parents:
|
|
@@ -290,6 +294,8 @@ def _convert_standalone_audits(
|
|
|
290
294
|
|
|
291
295
|
audit_definition_string = ";\n".join(stringified)
|
|
292
296
|
|
|
297
|
+
if audit._path is None:
|
|
298
|
+
continue
|
|
293
299
|
audit_filename = audit._path.relative_to(input_paths.tests)
|
|
294
300
|
audit_output_path = output_paths.audits / audit_filename
|
|
295
301
|
audit_output_path.write_text(audit_definition_string)
|
sqlmesh/lsp/reference.py
CHANGED
|
@@ -164,6 +164,9 @@ def get_model_definitions_for_a_path(
|
|
|
164
164
|
else:
|
|
165
165
|
return []
|
|
166
166
|
|
|
167
|
+
if file_path is None:
|
|
168
|
+
return []
|
|
169
|
+
|
|
167
170
|
# Find all possible references
|
|
168
171
|
references: t.List[Reference] = []
|
|
169
172
|
|
|
@@ -246,6 +249,8 @@ def get_model_definitions_for_a_path(
|
|
|
246
249
|
if referenced_model is None:
|
|
247
250
|
continue
|
|
248
251
|
referenced_model_path = referenced_model._path
|
|
252
|
+
if referenced_model_path is None:
|
|
253
|
+
continue
|
|
249
254
|
# Check whether the path exists
|
|
250
255
|
if not referenced_model_path.is_file():
|
|
251
256
|
continue
|
|
@@ -372,6 +377,9 @@ def get_macro_definitions_for_a_path(
|
|
|
372
377
|
else:
|
|
373
378
|
return []
|
|
374
379
|
|
|
380
|
+
if file_path is None:
|
|
381
|
+
return []
|
|
382
|
+
|
|
375
383
|
references = []
|
|
376
384
|
_, config_path = lsp_context.context.config_for_path(
|
|
377
385
|
file_path,
|
sqlmesh/magics.py
CHANGED
|
@@ -287,8 +287,9 @@ class SQLMeshMagics(Magics):
|
|
|
287
287
|
if loaded.name == args.model:
|
|
288
288
|
model = loaded
|
|
289
289
|
else:
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
if model._path:
|
|
291
|
+
with open(model._path, "r", encoding="utf-8") as file:
|
|
292
|
+
expressions = parse(file.read(), default_dialect=config.dialect)
|
|
292
293
|
|
|
293
294
|
formatted = format_model_expressions(
|
|
294
295
|
expressions,
|
|
@@ -307,8 +308,9 @@ class SQLMeshMagics(Magics):
|
|
|
307
308
|
replace=True,
|
|
308
309
|
)
|
|
309
310
|
|
|
310
|
-
|
|
311
|
-
|
|
311
|
+
if model._path:
|
|
312
|
+
with open(model._path, "w", encoding="utf-8") as file:
|
|
313
|
+
file.write(formatted)
|
|
312
314
|
|
|
313
315
|
if sql:
|
|
314
316
|
context.console.log_success(f"Model `{args.model}` updated")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
sqlmesh/__init__.py,sha256=QjwaamJIdW7voXoS880yAx7tHm-Im4_mqGA-XJgafos,7631
|
|
2
|
-
sqlmesh/_version.py,sha256=
|
|
3
|
-
sqlmesh/magics.py,sha256=
|
|
2
|
+
sqlmesh/_version.py,sha256=S9lEVv3QVWQs4d4mxXKYzMCuqOotm2m6JhCf7IGStXs,530
|
|
3
|
+
sqlmesh/magics.py,sha256=tdkXrxkZug6LZ5F8TH4lx_XNV3T8bHGYTJUlGJfPQ4A,41777
|
|
4
4
|
sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
sqlmesh/cicd/bot.py,sha256=2zlbn-DXkqQzr3lA0__IGU4XaIfXBXBKLWXNI2DRJX8,759
|
|
@@ -13,17 +13,17 @@ sqlmesh/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
13
13
|
sqlmesh/core/_typing.py,sha256=e1f7xO2aZCy38M_3VoDy-XI3shyd99-IFctgIFSgXWM,497
|
|
14
14
|
sqlmesh/core/console.py,sha256=ObpdArJOXDOihWPXsWIUuwiQ64cMlroNWJHqQPkVqC0,160753
|
|
15
15
|
sqlmesh/core/constants.py,sha256=gUABXWYgH_XOSbaZAJsR5o1dmA61JDCvBDyxqqXX3LM,2630
|
|
16
|
-
sqlmesh/core/context.py,sha256=
|
|
16
|
+
sqlmesh/core/context.py,sha256=IKZxD5BnbwLKCRFt4s02W4HZ5REXFiOnyl6Ywhc3yA8,124456
|
|
17
17
|
sqlmesh/core/context_diff.py,sha256=CeUmMBJzN__98YohrtAiIYPIZI9mrGBk6bVADWBLUw8,21692
|
|
18
18
|
sqlmesh/core/dialect.py,sha256=1ykYwb9WZn_nCaX08PcQ0BJh2Pihv9SPvoMNjpMeCfs,50158
|
|
19
19
|
sqlmesh/core/environment.py,sha256=7DbJX0r5nZRU3LhcgIxbSV-JosQYDjAt3V5Wc2Fpns8,13005
|
|
20
20
|
sqlmesh/core/lineage.py,sha256=zjB0Zfamo2Fja2r5SSZPMbrEKTXr1WjozZPVqvxdybI,3143
|
|
21
21
|
sqlmesh/core/loader.py,sha256=Imb65SX5TtvQrtlilin2hkYg12gm9e9c30I8o95nkVE,40534
|
|
22
|
-
sqlmesh/core/macros.py,sha256=
|
|
23
|
-
sqlmesh/core/node.py,sha256=
|
|
22
|
+
sqlmesh/core/macros.py,sha256=ogIHo_Eh-Calty9NFuJ-QpfLNFBSauK738mg_srv4iM,60626
|
|
23
|
+
sqlmesh/core/node.py,sha256=3ChBz1PIMJhp-jzed_GLBrtmEF2v_BVDEM5WNe0ssPk,14658
|
|
24
24
|
sqlmesh/core/notification_target.py,sha256=PPGoDrgbRKxr27vJEu03XqNTQLYTw0ZF_b0yAapxGeI,16158
|
|
25
25
|
sqlmesh/core/reference.py,sha256=k7OSkLqTjPR8WJjNeFj0xAJ297nZUMgb_iTVwKRRKjc,4875
|
|
26
|
-
sqlmesh/core/renderer.py,sha256=
|
|
26
|
+
sqlmesh/core/renderer.py,sha256=SVE1THHK1UVdPPHjmqNbBVIjmEYcK8tz5pWh1ss8xGs,26684
|
|
27
27
|
sqlmesh/core/scheduler.py,sha256=5qSC-EHKotWpwFFvnwDHw3feYfz9c8_9gBGRfdeu8P4,40512
|
|
28
28
|
sqlmesh/core/schema_diff.py,sha256=Sp2MoqAngp-yTYevkLaf9jb26SuAdGXoZ54g5MjWowU,30516
|
|
29
29
|
sqlmesh/core/schema_loader.py,sha256=lvrI9k7hr1P4X4E6t3U-KrcuvdQuw0UdNlN90P2s52w,3563
|
|
@@ -88,7 +88,7 @@ sqlmesh/core/model/__init__.py,sha256=C8GRZ53xuXEA9hQv3BQS9pNNyd9rZ06R_B96UYGhDu
|
|
|
88
88
|
sqlmesh/core/model/cache.py,sha256=csun0RJguHzKX6-qITcOs4fVP4f8_Ts8qiUVV4sHY6Q,7869
|
|
89
89
|
sqlmesh/core/model/common.py,sha256=dPyqXLaDSnQgDVdbiOZ7YwomlaPIvGfyL-mHhc7bR1o,17830
|
|
90
90
|
sqlmesh/core/model/decorator.py,sha256=wUUg5t0K559tV9Pqt6FE2EWXt5TPGb4wF2Yg4B4hX4w,9251
|
|
91
|
-
sqlmesh/core/model/definition.py,sha256=
|
|
91
|
+
sqlmesh/core/model/definition.py,sha256=HivkFcm2f7UclH4j0oXd0qbJm919uFjkE3lfo-Smtd8,112780
|
|
92
92
|
sqlmesh/core/model/kind.py,sha256=8Dp8yiTiXltboZWrB2FJ-LQ3zx4Fv_5Tj0KdUIPwCHI,36358
|
|
93
93
|
sqlmesh/core/model/meta.py,sha256=D9InI9M2-IXeb34vkXNQSLALL8xVXjZ_LXwI-Tqxm7I,21197
|
|
94
94
|
sqlmesh/core/model/schema.py,sha256=_HMYfzK9wWXh7_CQDIIGnuQUD4aiX3o5D2cRp2sERzc,3387
|
|
@@ -102,7 +102,7 @@ sqlmesh/core/plan/stages.py,sha256=7iiVZLSRoI1kSEMyOuuW6gvUA-eyALUfdW5vDh_N4jU,2
|
|
|
102
102
|
sqlmesh/core/snapshot/__init__.py,sha256=Z5HTetNCZGoKF1WAKXk4LWL9dc8EC8lwS2O4TtoBmt4,1317
|
|
103
103
|
sqlmesh/core/snapshot/cache.py,sha256=bgqCR2hyf6r2A_8QP1EnXFK25gDX37-Zg0YeMuETWxg,3934
|
|
104
104
|
sqlmesh/core/snapshot/categorizer.py,sha256=qGG5870mu1jR2whKisSBH_GFbsyh96RnzJDgkN7DV9g,2482
|
|
105
|
-
sqlmesh/core/snapshot/definition.py,sha256=
|
|
105
|
+
sqlmesh/core/snapshot/definition.py,sha256=DwYTNcDfPQUQ1osF_63SdicSj7oqVjtmPPEzqwsxDLU,85748
|
|
106
106
|
sqlmesh/core/snapshot/evaluator.py,sha256=yNVxlTIV8_mKmUsIJtQtjT8RZHDHA64pUPds9VZfOq8,90503
|
|
107
107
|
sqlmesh/core/state_sync/__init__.py,sha256=B60xj-_Xk-4jas3UphLvwkuf04G-9AyGckcblXE0aRg,869
|
|
108
108
|
sqlmesh/core/state_sync/base.py,sha256=AdqWmbhnvRFqVcFK6L01uCvpBVAYGuMrm4P0D3u_NaU,18334
|
|
@@ -145,14 +145,12 @@ sqlmesh/dbt/util.py,sha256=BdtfQ7sxnZ8y8CFJStkePpmRE-KntHCXTefRnXR5Pag,905
|
|
|
145
145
|
sqlmesh/dbt/converter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
146
146
|
sqlmesh/dbt/converter/common.py,sha256=APynHIN5aeL1hyetIib67O-zRcae-Mw-QEQEihcMVpI,1454
|
|
147
147
|
sqlmesh/dbt/converter/console.py,sha256=yTl08JyM_KM-Ya8VIX-l0r1rOsaxkBboiz-BbsF7SMU,4610
|
|
148
|
-
sqlmesh/dbt/converter/convert.py,sha256=
|
|
148
|
+
sqlmesh/dbt/converter/convert.py,sha256=CX3faG6oLhhItqghQTkqqpo2LaUdu3sIAeaofA4eymM,15854
|
|
149
149
|
sqlmesh/dbt/converter/jinja.py,sha256=LwtMRWcVYv16cVilOekBjoFfnD-OBfaP90JpYy34jiw,25279
|
|
150
150
|
sqlmesh/dbt/converter/jinja_builtins.py,sha256=EVWyDNn0wnSrn9T5TkmKdBBVdw0TzROlfwnSVgnMehM,4589
|
|
151
151
|
sqlmesh/dbt/converter/jinja_transforms.py,sha256=MkgL3Wky2mHzLaEIqkCwiYQk99jL19Wt2pOoXhsqtqQ,17597
|
|
152
152
|
sqlmesh/engines/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
153
|
-
sqlmesh/engines/commands.py,sha256=Fjy_seH1JL2EZxFNJBr0-eIaOn5PNY-JEb0nBbcr6Go,6094
|
|
154
153
|
sqlmesh/engines/spark/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
155
|
-
sqlmesh/engines/spark/app.py,sha256=du4Hh-3A7yHak54_CjL0W87X_Kl3btzHpUy9koIQXf4,3748
|
|
156
154
|
sqlmesh/engines/spark/db_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
157
155
|
sqlmesh/engines/spark/db_api/errors.py,sha256=LSXuHHhkzHvKlcdwmhCM9qm51KyKoP8gQH-p_W3Oow4,148
|
|
158
156
|
sqlmesh/engines/spark/db_api/spark_session.py,sha256=uQP0VFFYtp3N9mK7zKw6SoiGVhJDDYPylqx46yDwGEc,4667
|
|
@@ -173,7 +171,7 @@ sqlmesh/lsp/description.py,sha256=PjguwyVw5YeYSgT0JMhkf5U1Jry-sDPLvQ2caIR9JPQ,85
|
|
|
173
171
|
sqlmesh/lsp/helpers.py,sha256=EFc1u3-b7kSv5-tNwmKUDxId72RCLDBnN2lLTgRSzzQ,1020
|
|
174
172
|
sqlmesh/lsp/hints.py,sha256=j-blccBUil94yRoDjWfkSM0HqMmsKD6hP2TaWdWWVk4,3734
|
|
175
173
|
sqlmesh/lsp/main.py,sha256=TRuegZaC04cPDThtmz_zL6YqBpQz342brv1luIbDTZ8,38186
|
|
176
|
-
sqlmesh/lsp/reference.py,sha256=
|
|
174
|
+
sqlmesh/lsp/reference.py,sha256=CjIXCJ5qM5mHyKRyM1brKyvpK9oQfLI0LiNKHfjJuVw,32257
|
|
177
175
|
sqlmesh/lsp/rename.py,sha256=399v1vyVRHHxvbCHVcuS4Pl8K2N-Z60JdZ6e1znOI4s,4397
|
|
178
176
|
sqlmesh/lsp/uri.py,sha256=mvSLbZGmMTHPpliThOtVWiFcHnfJzp1w39q9l-xD2SI,802
|
|
179
177
|
sqlmesh/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -284,7 +282,7 @@ sqlmesh/utils/pydantic.py,sha256=o_NsXbIpDqNpUA1Uc5xF0ZzoXQYYB0DfHwdRxBwXPNk,120
|
|
|
284
282
|
sqlmesh/utils/rich.py,sha256=BpB47G0-JcU41LkGkeGKroexj4NOV5fox4-GOIXPgIc,3545
|
|
285
283
|
sqlmesh/utils/windows.py,sha256=r7Yin4WEwbvH7sKA3hOJtRsclmscNuBeCklCfVPvtQs,611
|
|
286
284
|
sqlmesh/utils/yaml.py,sha256=hvo5lmybYLcIx4p6CQwufS8X4MbwS60lEBnCmYJCXmU,2336
|
|
287
|
-
sqlmesh-0.199.1.
|
|
285
|
+
sqlmesh-0.199.1.dev35.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
|
|
288
286
|
web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
289
287
|
web/client/dist/index.html,sha256=DAv6ABGogw4xRLb0T_92WP_S7XWyqVhwBgGKWtuQwU4,5472
|
|
290
288
|
web/client/dist/assets/Audits-BuHAmFO8.js,sha256=zbYUF6WdUGMbnMm01GMNPb7xAJwj-o5wMdL56vPo2qE,1041
|
|
@@ -384,9 +382,9 @@ web/server/app.py,sha256=b6qEJ4btjaSm2kWwQUGV--S3VE8QW0Um7f4rBdaoB_M,59
|
|
|
384
382
|
web/server/console.py,sha256=CJlhoNBVUj_U5h_88gQgDJNzLOe2FAQ1DcFeMdO3H18,14583
|
|
385
383
|
web/server/exceptions.py,sha256=I2PPpChwhDWawQENr5kHg6DjyRGeiJ6OWZsCzEZhVzs,1533
|
|
386
384
|
web/server/main.py,sha256=9PaDa8sigo1z0AxtI3sQ3fHmDqs6uXwP-_IvoMwkznw,3199
|
|
387
|
-
web/server/models.py,sha256=
|
|
385
|
+
web/server/models.py,sha256=EzMxPLz_igDBZ3tMlI7niylVih_Hh7YITZAK3c8sOiA,15556
|
|
388
386
|
web/server/openapi.py,sha256=NOg__YQg7arVdajQv5CvOA5KLTQCfGZFvwnjARuM6iE,586
|
|
389
|
-
web/server/settings.py,sha256=
|
|
387
|
+
web/server/settings.py,sha256=_W50-Holci5Zv8goK7qATLRD1_Fcx-75gcNTVjdGDOc,3770
|
|
390
388
|
web/server/utils.py,sha256=bb6AOM3Nga-zihPjZvJeDL6sHqTPNC_SYjklsy8tAQA,4013
|
|
391
389
|
web/server/watcher.py,sha256=2c08EfXkgAfqpAEoFidkYjGH48DkLDyMueVp4afICHM,5334
|
|
392
390
|
web/server/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -398,12 +396,12 @@ web/server/api/endpoints/events.py,sha256=tjhOhGe9jt7L1mOLLapl5qTvicDRnP5lPZHSq9
|
|
|
398
396
|
web/server/api/endpoints/files.py,sha256=Rr0YS9Nz9vLH9KvGAfxbMlxN8j1XxU9CViFvlKoP2YQ,6747
|
|
399
397
|
web/server/api/endpoints/lineage.py,sha256=XU99RI-6Q9SidItGM5WLQMje8NhM5nZWHbtWxDwWeFE,6050
|
|
400
398
|
web/server/api/endpoints/meta.py,sha256=QKWWrHewGh5JS8mCSWXTKCIQwXw-TQfaT9tWt_SsNY4,1032
|
|
401
|
-
web/server/api/endpoints/models.py,sha256=
|
|
399
|
+
web/server/api/endpoints/models.py,sha256=kwj0s7uve3iZSMfmjkoPVMFMeY1sD0peTeyrWfzI0kI,4742
|
|
402
400
|
web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
|
|
403
401
|
web/server/api/endpoints/plan.py,sha256=bbbY50W_2MsZSTxOHWMKz0tbIm75nsRSlPy8GI2fg9Q,9306
|
|
404
402
|
web/server/api/endpoints/table_diff.py,sha256=SCy3-pr5x6bEEiOaZGCDbiHQhpgxwmnz3Acqa2Ie6jI,2090
|
|
405
|
-
sqlmesh-0.199.1.
|
|
406
|
-
sqlmesh-0.199.1.
|
|
407
|
-
sqlmesh-0.199.1.
|
|
408
|
-
sqlmesh-0.199.1.
|
|
409
|
-
sqlmesh-0.199.1.
|
|
403
|
+
sqlmesh-0.199.1.dev35.dist-info/METADATA,sha256=2O2l5ufMQveHcekXHm4RlUfVObh5Pq_sSG_gm5BLqWE,26659
|
|
404
|
+
sqlmesh-0.199.1.dev35.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
405
|
+
sqlmesh-0.199.1.dev35.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
|
|
406
|
+
sqlmesh-0.199.1.dev35.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
|
|
407
|
+
sqlmesh-0.199.1.dev35.dist-info/RECORD,,
|
|
@@ -121,11 +121,12 @@ def serialize_model(context: Context, model: Model, render_query: bool = False)
|
|
|
121
121
|
)
|
|
122
122
|
sql = query.sql(pretty=True, dialect=model.dialect)
|
|
123
123
|
|
|
124
|
+
path = model._path
|
|
124
125
|
return models.Model(
|
|
125
126
|
name=model.name,
|
|
126
127
|
fqn=model.fqn,
|
|
127
|
-
path=str(
|
|
128
|
-
full_path=str(
|
|
128
|
+
path=str(path.absolute().relative_to(context.path).as_posix()) if path else None,
|
|
129
|
+
full_path=str(path.absolute().as_posix()) if path else None,
|
|
129
130
|
dialect=dialect,
|
|
130
131
|
columns=columns,
|
|
131
132
|
details=details,
|
web/server/models.py
CHANGED
|
@@ -171,8 +171,8 @@ class Column(PydanticModel):
|
|
|
171
171
|
class Model(PydanticModel):
|
|
172
172
|
name: str
|
|
173
173
|
fqn: str
|
|
174
|
-
path: str
|
|
175
|
-
full_path: str
|
|
174
|
+
path: t.Optional[str] = None
|
|
175
|
+
full_path: t.Optional[str] = None
|
|
176
176
|
"""
|
|
177
177
|
As opposed to path, which is relative to the project root, full_path is the absolute path to the model file.
|
|
178
178
|
"""
|
web/server/settings.py
CHANGED
|
@@ -80,7 +80,7 @@ def _get_loaded_context(path: str | Path, config: str, gateway: str) -> Context:
|
|
|
80
80
|
|
|
81
81
|
@lru_cache()
|
|
82
82
|
def _get_path_to_model_mapping(context: Context) -> dict[Path, Model]:
|
|
83
|
-
return {model._path: model for model in context._models.values()}
|
|
83
|
+
return {model._path: model for model in context._models.values() if model._path}
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
def get_path_to_model_mapping(
|
sqlmesh/engines/commands.py
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import typing as t
|
|
2
|
-
from enum import Enum
|
|
3
|
-
|
|
4
|
-
from sqlglot import exp
|
|
5
|
-
from sqlmesh.core.environment import Environment, EnvironmentNamingInfo
|
|
6
|
-
from sqlmesh.core.snapshot import (
|
|
7
|
-
DeployabilityIndex,
|
|
8
|
-
Snapshot,
|
|
9
|
-
SnapshotEvaluator,
|
|
10
|
-
SnapshotId,
|
|
11
|
-
SnapshotTableCleanupTask,
|
|
12
|
-
SnapshotTableInfo,
|
|
13
|
-
)
|
|
14
|
-
from sqlmesh.core.state_sync import cleanup_expired_views
|
|
15
|
-
from sqlmesh.utils.date import TimeLike
|
|
16
|
-
from sqlmesh.utils.errors import AuditError
|
|
17
|
-
from sqlmesh.utils.pydantic import PydanticModel
|
|
18
|
-
|
|
19
|
-
COMMAND_PAYLOAD_FILE_NAME = "payload.json"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class CommandType(str, Enum):
|
|
23
|
-
EVALUATE = "evaluate"
|
|
24
|
-
PROMOTE = "promote"
|
|
25
|
-
DEMOTE = "demote"
|
|
26
|
-
CLEANUP = "cleanup"
|
|
27
|
-
CREATE_TABLES = "create_tables"
|
|
28
|
-
MIGRATE_TABLES = "migrate_tables"
|
|
29
|
-
|
|
30
|
-
# This makes it easy to integrate with argparse
|
|
31
|
-
def __str__(self) -> str:
|
|
32
|
-
return self.value
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class EvaluateCommandPayload(PydanticModel):
|
|
36
|
-
snapshot: Snapshot
|
|
37
|
-
parent_snapshots: t.Dict[str, Snapshot]
|
|
38
|
-
start: TimeLike
|
|
39
|
-
end: TimeLike
|
|
40
|
-
execution_time: TimeLike
|
|
41
|
-
deployability_index: DeployabilityIndex
|
|
42
|
-
batch_index: int
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
class PromoteCommandPayload(PydanticModel):
|
|
46
|
-
snapshots: t.List[Snapshot]
|
|
47
|
-
environment_naming_info: EnvironmentNamingInfo
|
|
48
|
-
deployability_index: DeployabilityIndex
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class DemoteCommandPayload(PydanticModel):
|
|
52
|
-
snapshots: t.List[SnapshotTableInfo]
|
|
53
|
-
environment_naming_info: EnvironmentNamingInfo
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
class CleanupCommandPayload(PydanticModel):
|
|
57
|
-
environments: t.List[Environment]
|
|
58
|
-
tasks: t.List[SnapshotTableCleanupTask]
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
class CreateTablesCommandPayload(PydanticModel):
|
|
62
|
-
target_snapshot_ids: t.List[SnapshotId]
|
|
63
|
-
snapshots: t.List[Snapshot]
|
|
64
|
-
deployability_index: DeployabilityIndex
|
|
65
|
-
allow_destructive_snapshots: t.Set[str]
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
class MigrateTablesCommandPayload(PydanticModel):
|
|
69
|
-
target_snapshot_ids: t.List[SnapshotId]
|
|
70
|
-
snapshots: t.List[Snapshot]
|
|
71
|
-
allow_destructive_snapshots: t.Set[str]
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def evaluate(
|
|
75
|
-
evaluator: SnapshotEvaluator, command_payload: t.Union[str, EvaluateCommandPayload]
|
|
76
|
-
) -> None:
|
|
77
|
-
if isinstance(command_payload, str):
|
|
78
|
-
command_payload = EvaluateCommandPayload.parse_raw(command_payload)
|
|
79
|
-
|
|
80
|
-
parent_snapshots = command_payload.parent_snapshots
|
|
81
|
-
parent_snapshots[command_payload.snapshot.name] = command_payload.snapshot
|
|
82
|
-
|
|
83
|
-
wap_id = evaluator.evaluate(
|
|
84
|
-
command_payload.snapshot,
|
|
85
|
-
start=command_payload.start,
|
|
86
|
-
end=command_payload.end,
|
|
87
|
-
execution_time=command_payload.execution_time,
|
|
88
|
-
snapshots=parent_snapshots,
|
|
89
|
-
deployability_index=command_payload.deployability_index,
|
|
90
|
-
batch_index=command_payload.batch_index,
|
|
91
|
-
)
|
|
92
|
-
audit_results = evaluator.audit(
|
|
93
|
-
snapshot=command_payload.snapshot,
|
|
94
|
-
start=command_payload.start,
|
|
95
|
-
end=command_payload.end,
|
|
96
|
-
execution_time=command_payload.execution_time,
|
|
97
|
-
snapshots=parent_snapshots,
|
|
98
|
-
deployability_index=command_payload.deployability_index,
|
|
99
|
-
wap_id=wap_id,
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
failed_audit_result = next((r for r in audit_results if r.count and r.blocking), None)
|
|
103
|
-
if failed_audit_result:
|
|
104
|
-
raise AuditError(
|
|
105
|
-
audit_name=failed_audit_result.audit.name,
|
|
106
|
-
audit_args=failed_audit_result.audit_args,
|
|
107
|
-
model=command_payload.snapshot.model_or_none,
|
|
108
|
-
count=t.cast(int, failed_audit_result.count),
|
|
109
|
-
query=t.cast(exp.Query, failed_audit_result.query),
|
|
110
|
-
adapter_dialect=evaluator.adapter.dialect,
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def promote(
|
|
115
|
-
evaluator: SnapshotEvaluator, command_payload: t.Union[str, PromoteCommandPayload]
|
|
116
|
-
) -> None:
|
|
117
|
-
if isinstance(command_payload, str):
|
|
118
|
-
command_payload = PromoteCommandPayload.parse_raw(command_payload)
|
|
119
|
-
evaluator.promote(
|
|
120
|
-
command_payload.snapshots,
|
|
121
|
-
command_payload.environment_naming_info,
|
|
122
|
-
deployability_index=command_payload.deployability_index,
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def demote(
|
|
127
|
-
evaluator: SnapshotEvaluator, command_payload: t.Union[str, DemoteCommandPayload]
|
|
128
|
-
) -> None:
|
|
129
|
-
if isinstance(command_payload, str):
|
|
130
|
-
command_payload = DemoteCommandPayload.parse_raw(command_payload)
|
|
131
|
-
evaluator.demote(
|
|
132
|
-
command_payload.snapshots,
|
|
133
|
-
command_payload.environment_naming_info,
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
def cleanup(
|
|
138
|
-
evaluator: SnapshotEvaluator, command_payload: t.Union[str, CleanupCommandPayload]
|
|
139
|
-
) -> None:
|
|
140
|
-
if isinstance(command_payload, str):
|
|
141
|
-
command_payload = CleanupCommandPayload.parse_raw(command_payload)
|
|
142
|
-
|
|
143
|
-
cleanup_expired_views(evaluator.adapter, evaluator.adapters, command_payload.environments)
|
|
144
|
-
evaluator.cleanup(command_payload.tasks)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
def create_tables(
|
|
148
|
-
evaluator: SnapshotEvaluator,
|
|
149
|
-
command_payload: t.Union[str, CreateTablesCommandPayload],
|
|
150
|
-
) -> None:
|
|
151
|
-
if isinstance(command_payload, str):
|
|
152
|
-
command_payload = CreateTablesCommandPayload.parse_raw(command_payload)
|
|
153
|
-
|
|
154
|
-
snapshots_by_id = {s.snapshot_id: s for s in command_payload.snapshots}
|
|
155
|
-
target_snapshots = [snapshots_by_id[sid] for sid in command_payload.target_snapshot_ids]
|
|
156
|
-
evaluator.create(
|
|
157
|
-
target_snapshots,
|
|
158
|
-
snapshots_by_id,
|
|
159
|
-
deployability_index=command_payload.deployability_index,
|
|
160
|
-
allow_destructive_snapshots=command_payload.allow_destructive_snapshots,
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
def migrate_tables(
|
|
165
|
-
evaluator: SnapshotEvaluator,
|
|
166
|
-
command_payload: t.Union[str, MigrateTablesCommandPayload],
|
|
167
|
-
) -> None:
|
|
168
|
-
if isinstance(command_payload, str):
|
|
169
|
-
command_payload = MigrateTablesCommandPayload.parse_raw(command_payload)
|
|
170
|
-
snapshots_by_id = {s.snapshot_id: s for s in command_payload.snapshots}
|
|
171
|
-
target_snapshots = [snapshots_by_id[sid] for sid in command_payload.target_snapshot_ids]
|
|
172
|
-
evaluator.migrate(
|
|
173
|
-
target_snapshots, snapshots_by_id, command_payload.allow_destructive_snapshots
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
COMMAND_HANDLERS: t.Dict[CommandType, t.Callable[[SnapshotEvaluator, str], None]] = {
|
|
178
|
-
CommandType.EVALUATE: evaluate,
|
|
179
|
-
CommandType.PROMOTE: promote,
|
|
180
|
-
CommandType.DEMOTE: demote,
|
|
181
|
-
CommandType.CLEANUP: cleanup,
|
|
182
|
-
CommandType.CREATE_TABLES: create_tables,
|
|
183
|
-
CommandType.MIGRATE_TABLES: migrate_tables,
|
|
184
|
-
}
|
sqlmesh/engines/spark/app.py
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
import logging
|
|
3
|
-
import os
|
|
4
|
-
import tempfile
|
|
5
|
-
|
|
6
|
-
from pyspark import SparkFiles
|
|
7
|
-
from pyspark.sql import SparkSession
|
|
8
|
-
|
|
9
|
-
from sqlmesh.core.engine_adapter import create_engine_adapter
|
|
10
|
-
from sqlmesh.core.snapshot import SnapshotEvaluator
|
|
11
|
-
from sqlmesh.engines import commands
|
|
12
|
-
from sqlmesh.engines.spark.db_api import spark_session as spark_session_db
|
|
13
|
-
from sqlmesh.engines.spark.db_api.errors import NotSupportedError
|
|
14
|
-
from sqlmesh.utils.errors import SQLMeshError
|
|
15
|
-
|
|
16
|
-
logger = logging.getLogger(__name__)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def get_or_create_spark_session(dialect: str) -> SparkSession:
|
|
20
|
-
if dialect == "databricks":
|
|
21
|
-
spark = SparkSession.getActiveSession()
|
|
22
|
-
if not spark:
|
|
23
|
-
raise SQLMeshError("Could not find an active SparkSession.")
|
|
24
|
-
return spark
|
|
25
|
-
return (
|
|
26
|
-
SparkSession.builder.config("spark.scheduler.mode", "FAIR")
|
|
27
|
-
.enableHiveSupport()
|
|
28
|
-
.getOrCreate()
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def main(
|
|
33
|
-
dialect: str,
|
|
34
|
-
default_catalog: str,
|
|
35
|
-
command_type: commands.CommandType,
|
|
36
|
-
ddl_concurrent_tasks: int,
|
|
37
|
-
payload_path: str,
|
|
38
|
-
) -> None:
|
|
39
|
-
if dialect not in ("databricks", "spark"):
|
|
40
|
-
raise NotSupportedError(
|
|
41
|
-
f"Dialect '{dialect}' not supported. Must be either 'databricks' or 'spark'"
|
|
42
|
-
)
|
|
43
|
-
logging.basicConfig(
|
|
44
|
-
format="%(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)",
|
|
45
|
-
level=logging.INFO,
|
|
46
|
-
)
|
|
47
|
-
command_handler = commands.COMMAND_HANDLERS.get(command_type)
|
|
48
|
-
if not command_handler:
|
|
49
|
-
raise NotSupportedError(f"Command '{command_type.value}' not supported")
|
|
50
|
-
|
|
51
|
-
spark = get_or_create_spark_session(dialect)
|
|
52
|
-
|
|
53
|
-
evaluator = SnapshotEvaluator(
|
|
54
|
-
create_engine_adapter(
|
|
55
|
-
lambda: spark_session_db.connection(spark),
|
|
56
|
-
dialect,
|
|
57
|
-
default_catalog=default_catalog,
|
|
58
|
-
multithreaded=ddl_concurrent_tasks > 1,
|
|
59
|
-
execute_log_level=logging.INFO,
|
|
60
|
-
),
|
|
61
|
-
ddl_concurrent_tasks=ddl_concurrent_tasks,
|
|
62
|
-
)
|
|
63
|
-
if dialect == "spark":
|
|
64
|
-
with open(SparkFiles.get(payload_path), "r", encoding="utf-8") as payload_fd:
|
|
65
|
-
command_payload = payload_fd.read()
|
|
66
|
-
else:
|
|
67
|
-
from pyspark.dbutils import DBUtils # type: ignore
|
|
68
|
-
|
|
69
|
-
dbutils = DBUtils(spark)
|
|
70
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
71
|
-
local_payload_path = os.path.join(tmp, commands.COMMAND_PAYLOAD_FILE_NAME)
|
|
72
|
-
dbutils.fs.cp(payload_path, f"file://{local_payload_path}")
|
|
73
|
-
with open(local_payload_path, "r", encoding="utf-8") as payload_fd:
|
|
74
|
-
command_payload = payload_fd.read()
|
|
75
|
-
logger.info("Command payload:\n %s", command_payload)
|
|
76
|
-
command_handler(evaluator, command_payload)
|
|
77
|
-
|
|
78
|
-
evaluator.close()
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if __name__ == "__main__":
|
|
82
|
-
parser = argparse.ArgumentParser(description="SQLMesh Spark Submit App")
|
|
83
|
-
parser.add_argument(
|
|
84
|
-
"--dialect",
|
|
85
|
-
help="The dialect to use when creating the engine adapter.",
|
|
86
|
-
)
|
|
87
|
-
parser.add_argument(
|
|
88
|
-
"--default_catalog",
|
|
89
|
-
help="The default catalog to use when creating the engine adapter.",
|
|
90
|
-
)
|
|
91
|
-
parser.add_argument(
|
|
92
|
-
"--command_type",
|
|
93
|
-
type=commands.CommandType,
|
|
94
|
-
choices=list(commands.CommandType),
|
|
95
|
-
help="The type of command that is being run",
|
|
96
|
-
)
|
|
97
|
-
parser.add_argument(
|
|
98
|
-
"--ddl_concurrent_tasks",
|
|
99
|
-
type=int,
|
|
100
|
-
default=1,
|
|
101
|
-
help="The number of ddl concurrent tasks to use. Default to 1.",
|
|
102
|
-
)
|
|
103
|
-
parser.add_argument(
|
|
104
|
-
"--payload_path",
|
|
105
|
-
help="Path to the payload object. Can be a local or remote path.",
|
|
106
|
-
)
|
|
107
|
-
args = parser.parse_args()
|
|
108
|
-
main(
|
|
109
|
-
args.dialect,
|
|
110
|
-
args.default_catalog,
|
|
111
|
-
args.command_type,
|
|
112
|
-
args.ddl_concurrent_tasks,
|
|
113
|
-
args.payload_path,
|
|
114
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|