sqlmesh 0.231.2.dev4__py3-none-any.whl → 0.232.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlmesh/_version.py +8 -18
- sqlmesh/cli/main.py +1 -1
- sqlmesh/core/_typing.py +2 -2
- sqlmesh/core/audit/definition.py +14 -16
- sqlmesh/core/config/connection.py +2 -0
- sqlmesh/core/config/linter.py +1 -1
- sqlmesh/core/config/model.py +3 -3
- sqlmesh/core/context.py +11 -11
- sqlmesh/core/context_diff.py +1 -1
- sqlmesh/core/dialect.py +92 -78
- sqlmesh/core/engine_adapter/athena.py +15 -15
- sqlmesh/core/engine_adapter/base.py +49 -51
- sqlmesh/core/engine_adapter/base_postgres.py +1 -1
- sqlmesh/core/engine_adapter/bigquery.py +23 -19
- sqlmesh/core/engine_adapter/clickhouse.py +19 -23
- sqlmesh/core/engine_adapter/databricks.py +6 -6
- sqlmesh/core/engine_adapter/duckdb.py +2 -2
- sqlmesh/core/engine_adapter/mixins.py +36 -39
- sqlmesh/core/engine_adapter/mssql.py +5 -5
- sqlmesh/core/engine_adapter/mysql.py +1 -1
- sqlmesh/core/engine_adapter/postgres.py +4 -4
- sqlmesh/core/engine_adapter/redshift.py +8 -8
- sqlmesh/core/engine_adapter/snowflake.py +16 -16
- sqlmesh/core/engine_adapter/spark.py +3 -3
- sqlmesh/core/engine_adapter/trino.py +5 -5
- sqlmesh/core/lineage.py +3 -3
- sqlmesh/core/macros.py +54 -60
- sqlmesh/core/metric/definition.py +9 -9
- sqlmesh/core/metric/rewriter.py +8 -8
- sqlmesh/core/model/cache.py +1 -1
- sqlmesh/core/model/common.py +19 -19
- sqlmesh/core/model/decorator.py +1 -1
- sqlmesh/core/model/definition.py +55 -55
- sqlmesh/core/model/kind.py +32 -29
- sqlmesh/core/model/meta.py +43 -21
- sqlmesh/core/model/seed.py +2 -2
- sqlmesh/core/node.py +4 -4
- sqlmesh/core/plan/builder.py +1 -1
- sqlmesh/core/reference.py +1 -1
- sqlmesh/core/renderer.py +12 -12
- sqlmesh/core/schema_diff.py +8 -10
- sqlmesh/core/selector.py +6 -6
- sqlmesh/core/snapshot/evaluator.py +8 -8
- sqlmesh/core/state_sync/common.py +8 -8
- sqlmesh/core/state_sync/db/environment.py +3 -3
- sqlmesh/core/state_sync/db/migrator.py +1 -1
- sqlmesh/core/state_sync/db/snapshot.py +1 -1
- sqlmesh/core/state_sync/db/utils.py +2 -4
- sqlmesh/core/state_sync/export_import.py +1 -1
- sqlmesh/core/table_diff.py +9 -9
- sqlmesh/core/test/definition.py +2 -2
- sqlmesh/dbt/column.py +1 -1
- sqlmesh/dbt/model.py +1 -1
- sqlmesh/lsp/hints.py +2 -3
- sqlmesh/lsp/reference.py +1 -1
- sqlmesh/migrations/v0092_warn_about_dbt_data_type_diff.py +2 -2
- sqlmesh/utils/date.py +2 -2
- sqlmesh/utils/jinja.py +7 -1
- sqlmesh/utils/lineage.py +5 -1
- sqlmesh/utils/metaprogramming.py +36 -1
- sqlmesh/utils/pydantic.py +18 -20
- {sqlmesh-0.231.2.dev4.dist-info → sqlmesh-0.232.0.dist-info}/METADATA +12 -10
- {sqlmesh-0.231.2.dev4.dist-info → sqlmesh-0.232.0.dist-info}/RECORD +68 -68
- web/server/api/endpoints/table_diff.py +1 -1
- {sqlmesh-0.231.2.dev4.dist-info → sqlmesh-0.232.0.dist-info}/WHEEL +0 -0
- {sqlmesh-0.231.2.dev4.dist-info → sqlmesh-0.232.0.dist-info}/entry_points.txt +0 -0
- {sqlmesh-0.231.2.dev4.dist-info → sqlmesh-0.232.0.dist-info}/licenses/LICENSE +0 -0
- {sqlmesh-0.231.2.dev4.dist-info → sqlmesh-0.232.0.dist-info}/top_level.txt +0 -0
sqlmesh/_version.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
# file generated by
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
2
|
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
__all__ = [
|
|
5
6
|
"__version__",
|
|
@@ -10,25 +11,14 @@ __all__ = [
|
|
|
10
11
|
"commit_id",
|
|
11
12
|
]
|
|
12
13
|
|
|
13
|
-
TYPE_CHECKING = False
|
|
14
|
-
if TYPE_CHECKING:
|
|
15
|
-
from typing import Tuple
|
|
16
|
-
from typing import Union
|
|
17
|
-
|
|
18
|
-
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
-
COMMIT_ID = Union[str, None]
|
|
20
|
-
else:
|
|
21
|
-
VERSION_TUPLE = object
|
|
22
|
-
COMMIT_ID = object
|
|
23
|
-
|
|
24
14
|
version: str
|
|
25
15
|
__version__: str
|
|
26
|
-
__version_tuple__:
|
|
27
|
-
version_tuple:
|
|
28
|
-
commit_id:
|
|
29
|
-
__commit_id__:
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
30
20
|
|
|
31
|
-
__version__ = version = '0.
|
|
32
|
-
__version_tuple__ = version_tuple = (0,
|
|
21
|
+
__version__ = version = '0.232.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 232, 0)
|
|
33
23
|
|
|
34
24
|
__commit_id__ = commit_id = None
|
sqlmesh/cli/main.py
CHANGED
sqlmesh/core/_typing.py
CHANGED
|
@@ -8,8 +8,8 @@ from sqlglot import exp
|
|
|
8
8
|
if t.TYPE_CHECKING:
|
|
9
9
|
TableName = t.Union[str, exp.Table]
|
|
10
10
|
SchemaName = t.Union[str, exp.Table]
|
|
11
|
-
SessionProperties = t.Dict[str, t.Union[exp.
|
|
12
|
-
CustomMaterializationProperties = t.Dict[str, t.Union[exp.
|
|
11
|
+
SessionProperties = t.Dict[str, t.Union[exp.Expr, str, int, float, bool]]
|
|
12
|
+
CustomMaterializationProperties = t.Dict[str, t.Union[exp.Expr, str, int, float, bool]]
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
if sys.version_info >= (3, 11):
|
sqlmesh/core/audit/definition.py
CHANGED
|
@@ -67,7 +67,7 @@ class AuditMixin(AuditCommonMetaMixin):
|
|
|
67
67
|
"""
|
|
68
68
|
|
|
69
69
|
query_: ParsableSql
|
|
70
|
-
defaults: t.Dict[str, exp.
|
|
70
|
+
defaults: t.Dict[str, exp.Expr]
|
|
71
71
|
expressions_: t.Optional[t.List[ParsableSql]]
|
|
72
72
|
jinja_macros: JinjaMacroRegistry
|
|
73
73
|
formatting: t.Optional[bool]
|
|
@@ -77,10 +77,10 @@ class AuditMixin(AuditCommonMetaMixin):
|
|
|
77
77
|
return t.cast(t.Union[exp.Query, d.JinjaQuery], self.query_.parse(self.dialect))
|
|
78
78
|
|
|
79
79
|
@property
|
|
80
|
-
def expressions(self) -> t.List[exp.
|
|
80
|
+
def expressions(self) -> t.List[exp.Expr]:
|
|
81
81
|
if not self.expressions_:
|
|
82
82
|
return []
|
|
83
|
-
result = []
|
|
83
|
+
result: t.List[exp.Expr] = []
|
|
84
84
|
for e in self.expressions_:
|
|
85
85
|
parsed = e.parse(self.dialect)
|
|
86
86
|
if not isinstance(parsed, exp.Semicolon):
|
|
@@ -95,7 +95,7 @@ class AuditMixin(AuditCommonMetaMixin):
|
|
|
95
95
|
|
|
96
96
|
@field_validator("name", "dialect", mode="before", check_fields=False)
|
|
97
97
|
def audit_string_validator(cls: t.Type, v: t.Any) -> t.Optional[str]:
|
|
98
|
-
if isinstance(v, exp.
|
|
98
|
+
if isinstance(v, exp.Expr):
|
|
99
99
|
return v.name.lower()
|
|
100
100
|
return str(v).lower() if v is not None else None
|
|
101
101
|
|
|
@@ -111,9 +111,7 @@ def audit_map_validator(cls: t.Type, v: t.Any, values: t.Any) -> t.Dict[str, t.A
|
|
|
111
111
|
if isinstance(v, dict):
|
|
112
112
|
dialect = get_dialect(values)
|
|
113
113
|
return {
|
|
114
|
-
key: value
|
|
115
|
-
if isinstance(value, exp.Expression)
|
|
116
|
-
else d.parse_one(str(value), dialect=dialect)
|
|
114
|
+
key: value if isinstance(value, exp.Expr) else d.parse_one(str(value), dialect=dialect)
|
|
117
115
|
for key, value in v.items()
|
|
118
116
|
}
|
|
119
117
|
raise_config_error("Defaults must be a tuple of exp.EQ or a dict", error_type=AuditConfigError)
|
|
@@ -133,7 +131,7 @@ class ModelAudit(PydanticModel, AuditMixin, DbtInfoMixin, frozen=True):
|
|
|
133
131
|
blocking: bool = True
|
|
134
132
|
standalone: t.Literal[False] = False
|
|
135
133
|
query_: ParsableSql = Field(alias="query")
|
|
136
|
-
defaults: t.Dict[str, exp.
|
|
134
|
+
defaults: t.Dict[str, exp.Expr] = {}
|
|
137
135
|
expressions_: t.Optional[t.List[ParsableSql]] = Field(default=None, alias="expressions")
|
|
138
136
|
jinja_macros: JinjaMacroRegistry = JinjaMacroRegistry()
|
|
139
137
|
formatting: t.Optional[bool] = Field(default=None, exclude=True)
|
|
@@ -169,7 +167,7 @@ class StandaloneAudit(_Node, AuditMixin):
|
|
|
169
167
|
blocking: bool = False
|
|
170
168
|
standalone: t.Literal[True] = True
|
|
171
169
|
query_: ParsableSql = Field(alias="query")
|
|
172
|
-
defaults: t.Dict[str, exp.
|
|
170
|
+
defaults: t.Dict[str, exp.Expr] = {}
|
|
173
171
|
expressions_: t.Optional[t.List[ParsableSql]] = Field(default=None, alias="expressions")
|
|
174
172
|
jinja_macros: JinjaMacroRegistry = JinjaMacroRegistry()
|
|
175
173
|
default_catalog: t.Optional[str] = None
|
|
@@ -323,13 +321,13 @@ class StandaloneAudit(_Node, AuditMixin):
|
|
|
323
321
|
include_python: bool = True,
|
|
324
322
|
include_defaults: bool = False,
|
|
325
323
|
render_query: bool = False,
|
|
326
|
-
) -> t.List[exp.
|
|
324
|
+
) -> t.List[exp.Expr]:
|
|
327
325
|
"""Returns the original list of sql expressions comprising the model definition.
|
|
328
326
|
|
|
329
327
|
Args:
|
|
330
328
|
include_python: Whether or not to include Python code in the rendered definition.
|
|
331
329
|
"""
|
|
332
|
-
expressions: t.List[exp.
|
|
330
|
+
expressions: t.List[exp.Expr] = []
|
|
333
331
|
comment = None
|
|
334
332
|
for field_name in sorted(self.meta_fields):
|
|
335
333
|
field_value = getattr(self, field_name)
|
|
@@ -381,7 +379,7 @@ class StandaloneAudit(_Node, AuditMixin):
|
|
|
381
379
|
return set(AuditCommonMetaMixin.__annotations__) | set(_Node.all_field_infos())
|
|
382
380
|
|
|
383
381
|
@property
|
|
384
|
-
def audits_with_args(self) -> t.List[t.Tuple[Audit, t.Dict[str, exp.
|
|
382
|
+
def audits_with_args(self) -> t.List[t.Tuple[Audit, t.Dict[str, exp.Expr]]]:
|
|
385
383
|
return [(self, {})]
|
|
386
384
|
|
|
387
385
|
|
|
@@ -389,7 +387,7 @@ Audit = t.Union[ModelAudit, StandaloneAudit]
|
|
|
389
387
|
|
|
390
388
|
|
|
391
389
|
def load_audit(
|
|
392
|
-
expressions: t.List[exp.
|
|
390
|
+
expressions: t.List[exp.Expr],
|
|
393
391
|
*,
|
|
394
392
|
path: Path = Path(),
|
|
395
393
|
module_path: Path = Path(),
|
|
@@ -499,7 +497,7 @@ def load_audit(
|
|
|
499
497
|
|
|
500
498
|
|
|
501
499
|
def load_multiple_audits(
|
|
502
|
-
expressions: t.List[exp.
|
|
500
|
+
expressions: t.List[exp.Expr],
|
|
503
501
|
*,
|
|
504
502
|
path: Path = Path(),
|
|
505
503
|
module_path: Path = Path(),
|
|
@@ -510,7 +508,7 @@ def load_multiple_audits(
|
|
|
510
508
|
variables: t.Optional[t.Dict[str, t.Any]] = None,
|
|
511
509
|
project: t.Optional[str] = None,
|
|
512
510
|
) -> t.Generator[Audit, None, None]:
|
|
513
|
-
audit_block: t.List[exp.
|
|
511
|
+
audit_block: t.List[exp.Expr] = []
|
|
514
512
|
for expression in expressions:
|
|
515
513
|
if isinstance(expression, d.Audit):
|
|
516
514
|
if audit_block:
|
|
@@ -543,7 +541,7 @@ def _raise_config_error(msg: str, path: pathlib.Path) -> None:
|
|
|
543
541
|
|
|
544
542
|
# mypy doesn't realize raise_config_error raises an exception
|
|
545
543
|
@t.no_type_check
|
|
546
|
-
def _maybe_parse_arg_pair(e: exp.
|
|
544
|
+
def _maybe_parse_arg_pair(e: exp.Expr) -> t.Tuple[str, exp.Expr]:
|
|
547
545
|
if isinstance(e, exp.EQ):
|
|
548
546
|
return e.left.name, e.right
|
|
549
547
|
|
|
@@ -1062,6 +1062,7 @@ class BigQueryConnectionConfig(ConnectionConfig):
|
|
|
1062
1062
|
job_retry_deadline_seconds: t.Optional[int] = None
|
|
1063
1063
|
priority: t.Optional[BigQueryPriority] = None
|
|
1064
1064
|
maximum_bytes_billed: t.Optional[int] = None
|
|
1065
|
+
reservation: t.Optional[str] = None
|
|
1065
1066
|
|
|
1066
1067
|
concurrent_tasks: int = 1
|
|
1067
1068
|
register_comments: bool = True
|
|
@@ -1171,6 +1172,7 @@ class BigQueryConnectionConfig(ConnectionConfig):
|
|
|
1171
1172
|
"job_retry_deadline_seconds",
|
|
1172
1173
|
"priority",
|
|
1173
1174
|
"maximum_bytes_billed",
|
|
1175
|
+
"reservation",
|
|
1174
1176
|
}
|
|
1175
1177
|
}
|
|
1176
1178
|
|
sqlmesh/core/config/linter.py
CHANGED
|
@@ -34,7 +34,7 @@ class LinterConfig(BaseConfig):
|
|
|
34
34
|
v = v.unnest().name
|
|
35
35
|
elif isinstance(v, (exp.Tuple, exp.Array)):
|
|
36
36
|
v = [e.name for e in v.expressions]
|
|
37
|
-
elif isinstance(v, exp.
|
|
37
|
+
elif isinstance(v, exp.Expr):
|
|
38
38
|
v = v.name
|
|
39
39
|
|
|
40
40
|
return {name.lower() for name in ensure_collection(v)}
|
sqlmesh/core/config/model.py
CHANGED
|
@@ -71,9 +71,9 @@ class ModelDefaultsConfig(BaseConfig):
|
|
|
71
71
|
enabled: t.Optional[t.Union[str, bool]] = None
|
|
72
72
|
formatting: t.Optional[t.Union[str, bool]] = None
|
|
73
73
|
batch_concurrency: t.Optional[int] = None
|
|
74
|
-
pre_statements: t.Optional[t.List[t.Union[str, exp.
|
|
75
|
-
post_statements: t.Optional[t.List[t.Union[str, exp.
|
|
76
|
-
on_virtual_update: t.Optional[t.List[t.Union[str, exp.
|
|
74
|
+
pre_statements: t.Optional[t.List[t.Union[str, exp.Expr]]] = None
|
|
75
|
+
post_statements: t.Optional[t.List[t.Union[str, exp.Expr]]] = None
|
|
76
|
+
on_virtual_update: t.Optional[t.List[t.Union[str, exp.Expr]]] = None
|
|
77
77
|
|
|
78
78
|
_model_kind_validator = model_kind_validator
|
|
79
79
|
_on_destructive_change_validator = on_destructive_change_validator
|
sqlmesh/core/context.py
CHANGED
|
@@ -234,7 +234,7 @@ class BaseContext(abc.ABC):
|
|
|
234
234
|
)
|
|
235
235
|
|
|
236
236
|
def fetchdf(
|
|
237
|
-
self, query: t.Union[exp.
|
|
237
|
+
self, query: t.Union[exp.Expr, str], quote_identifiers: bool = False
|
|
238
238
|
) -> pd.DataFrame:
|
|
239
239
|
"""Fetches a dataframe given a sql string or sqlglot expression.
|
|
240
240
|
|
|
@@ -248,7 +248,7 @@ class BaseContext(abc.ABC):
|
|
|
248
248
|
return self.engine_adapter.fetchdf(query, quote_identifiers=quote_identifiers)
|
|
249
249
|
|
|
250
250
|
def fetch_pyspark_df(
|
|
251
|
-
self, query: t.Union[exp.
|
|
251
|
+
self, query: t.Union[exp.Expr, str], quote_identifiers: bool = False
|
|
252
252
|
) -> PySparkDataFrame:
|
|
253
253
|
"""Fetches a PySpark dataframe given a sql string or sqlglot expression.
|
|
254
254
|
|
|
@@ -1105,7 +1105,7 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
1105
1105
|
execution_time: t.Optional[TimeLike] = None,
|
|
1106
1106
|
expand: t.Union[bool, t.Iterable[str]] = False,
|
|
1107
1107
|
**kwargs: t.Any,
|
|
1108
|
-
) -> exp.
|
|
1108
|
+
) -> exp.Expr:
|
|
1109
1109
|
"""Renders a model's query, expanding macros with provided kwargs, and optionally expanding referenced models.
|
|
1110
1110
|
|
|
1111
1111
|
Args:
|
|
@@ -1860,10 +1860,10 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
1860
1860
|
self,
|
|
1861
1861
|
source: str,
|
|
1862
1862
|
target: str,
|
|
1863
|
-
on: t.Optional[t.List[str] | exp.
|
|
1863
|
+
on: t.Optional[t.List[str] | exp.Expr] = None,
|
|
1864
1864
|
skip_columns: t.Optional[t.List[str]] = None,
|
|
1865
1865
|
select_models: t.Optional[t.Collection[str]] = None,
|
|
1866
|
-
where: t.Optional[str | exp.
|
|
1866
|
+
where: t.Optional[str | exp.Expr] = None,
|
|
1867
1867
|
limit: int = 20,
|
|
1868
1868
|
show: bool = True,
|
|
1869
1869
|
show_sample: bool = True,
|
|
@@ -1922,7 +1922,7 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
1922
1922
|
raise SQLMeshError(e)
|
|
1923
1923
|
|
|
1924
1924
|
models_to_diff: t.List[
|
|
1925
|
-
t.Tuple[Model, EngineAdapter, str, str, t.Optional[t.List[str] | exp.
|
|
1925
|
+
t.Tuple[Model, EngineAdapter, str, str, t.Optional[t.List[str] | exp.Expr]]
|
|
1926
1926
|
] = []
|
|
1927
1927
|
models_without_grain: t.List[Model] = []
|
|
1928
1928
|
source_snapshots_to_name = {
|
|
@@ -2041,9 +2041,9 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
2041
2041
|
target_alias: str,
|
|
2042
2042
|
limit: int,
|
|
2043
2043
|
decimals: int,
|
|
2044
|
-
on: t.Optional[t.List[str] | exp.
|
|
2044
|
+
on: t.Optional[t.List[str] | exp.Expr] = None,
|
|
2045
2045
|
skip_columns: t.Optional[t.List[str]] = None,
|
|
2046
|
-
where: t.Optional[str | exp.
|
|
2046
|
+
where: t.Optional[str | exp.Expr] = None,
|
|
2047
2047
|
show: bool = True,
|
|
2048
2048
|
temp_schema: t.Optional[str] = None,
|
|
2049
2049
|
skip_grain_check: bool = False,
|
|
@@ -2083,10 +2083,10 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
2083
2083
|
limit: int,
|
|
2084
2084
|
decimals: int,
|
|
2085
2085
|
adapter: EngineAdapter,
|
|
2086
|
-
on: t.Optional[t.List[str] | exp.
|
|
2086
|
+
on: t.Optional[t.List[str] | exp.Expr] = None,
|
|
2087
2087
|
model: t.Optional[Model] = None,
|
|
2088
2088
|
skip_columns: t.Optional[t.List[str]] = None,
|
|
2089
|
-
where: t.Optional[str | exp.
|
|
2089
|
+
where: t.Optional[str | exp.Expr] = None,
|
|
2090
2090
|
schema_diff_ignore_case: bool = False,
|
|
2091
2091
|
) -> TableDiff:
|
|
2092
2092
|
if not on:
|
|
@@ -2344,7 +2344,7 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
2344
2344
|
return not errors
|
|
2345
2345
|
|
|
2346
2346
|
@python_api_analytics
|
|
2347
|
-
def rewrite(self, sql: str, dialect: str = "") -> exp.
|
|
2347
|
+
def rewrite(self, sql: str, dialect: str = "") -> exp.Expr:
|
|
2348
2348
|
"""Rewrite a sql expression with semantic references into an executable query.
|
|
2349
2349
|
|
|
2350
2350
|
https://sqlmesh.readthedocs.io/en/latest/concepts/metrics/overview/
|
sqlmesh/core/context_diff.py
CHANGED
|
@@ -36,7 +36,7 @@ if t.TYPE_CHECKING:
|
|
|
36
36
|
from sqlmesh.utils.metaprogramming import Executable # noqa
|
|
37
37
|
from sqlmesh.core.environment import EnvironmentStatements
|
|
38
38
|
|
|
39
|
-
IGNORED_PACKAGES = {"sqlmesh", "sqlglot"}
|
|
39
|
+
IGNORED_PACKAGES = {"sqlmesh", "sqlglot", "sqlglotc"}
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
class ContextDiff(PydanticModel):
|