Skip to content

Commit e0c0d3b

Browse files
Merge remote-tracking branch 'upstream/main' into feat/add-fabric-engine
2 parents 0569051 + d1d8766 commit e0c0d3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2494
-928
lines changed

docs/examples/incremental_time_full_walkthrough.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ We have data like the below that gets ingested into our data warehouse on a dail
172172

173173
I can answer some of the questions above by walking through the model's config, coupled with the business logic/code I prepared ahead of time.
174174

175-
You can see this code in a SQLMesh project context [here](https://github.com/sungchun12/sqlmesh-demos/blob/incremental-demo/models/examples/incrementals_demo.sql).
175+
You can see this code in a SQLMesh project context [here](https://github.com/sungchun12/sqlmesh-demos/blob/incremental-demo/models/examples/incremental_model.sql).
176176

177177
```sql
178178
MODEL (

docs/guides/linter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ This example specifies that the model `docs_example.full_model` should not run t
221221
```sql linenums="1"
222222
MODEL(
223223
name docs_example.full_model,
224-
ignored_rules: ["invalidselectstarexpansion"] # or "ALL" to turn off linting completely
224+
ignored_rules ["invalidselectstarexpansion"] # or "ALL" to turn off linting completely
225225
);
226226
```
227227

docs/guides/ui.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Browser UI guide
22

3+
!!! warning
4+
5+
Browser UI is deprecated. Please use the [VSCode extension](vscode.md) instead.
6+
7+
38
SQLMesh's free, open-source browser user interface (UI) makes it easy to understand, explore, and modify your SQLMesh project.
49

510
This page describes the UI's components and how they work.

docs/quickstart/ui.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Browser UI
22

3+
!!! warning
4+
5+
Browser UI is deprecated. Please use the [VSCode extension](../guides/vscode.md) instead.
6+
37
In this quickstart, you'll use the SQLMesh browser user interface to get up and running with SQLMesh's scaffold generator. This example project will run locally on your computer using [DuckDB](https://duckdb.org/) as an embedded SQL engine.
48

59
??? info "Learn more about the quickstart project structure"

pnpm-lock.yaml

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies = [
1111
"click",
1212
"croniter",
1313
"duckdb>=0.10.0,!=0.10.3",
14-
"dateparser",
14+
"dateparser<=1.2.1",
1515
"hyperscript>=0.1.0",
1616
"importlib-metadata; python_version<'3.12'",
1717
"ipywidgets",

sqlmesh/cli/main.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ def cli(
107107
if "--help" in sys.argv:
108108
return
109109

110+
configure_logging(
111+
debug,
112+
log_to_stdout,
113+
log_file_dir=log_file_dir,
114+
ignore_warnings=ignore_warnings,
115+
)
116+
configure_console(ignore_warnings=ignore_warnings)
117+
110118
load = True
111119

112120
if len(paths) == 1:
@@ -117,14 +125,6 @@ def cli(
117125
if ctx.invoked_subcommand in SKIP_LOAD_COMMANDS:
118126
load = False
119127

120-
configure_logging(
121-
debug,
122-
log_to_stdout,
123-
log_file_dir=log_file_dir,
124-
ignore_warnings=ignore_warnings,
125-
)
126-
configure_console(ignore_warnings=ignore_warnings)
127-
128128
configs = load_configs(config, Context.CONFIG_TYPE, paths, dotenv_path=dotenv)
129129
log_limit = list(configs.values())[0].log_limit
130130

@@ -884,6 +884,13 @@ def info(obj: Context, skip_connection: bool, verbose: int) -> None:
884884
@cli_analytics
885885
def ui(ctx: click.Context, host: str, port: int, mode: str) -> None:
886886
"""Start a browser-based SQLMesh UI."""
887+
from sqlmesh.core.console import get_console
888+
889+
get_console().log_warning(
890+
"The UI is deprecated and will be removed in a future version. Please use the SQLMesh VSCode extension instead. "
891+
"Learn more at https://sqlmesh.readthedocs.io/en/stable/guides/vscode/"
892+
)
893+
887894
try:
888895
import uvicorn
889896
except ModuleNotFoundError as e:

sqlmesh/core/engine_adapter/duckdb.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,56 @@ def _normalize_decimal_value(self, col: exp.Expression, precision: int) -> exp.E
142142
exp.cast(col, "DOUBLE"),
143143
f"DECIMAL(38, {precision})",
144144
)
145+
146+
def _create_table(
147+
self,
148+
table_name_or_schema: t.Union[exp.Schema, TableName],
149+
expression: t.Optional[exp.Expression],
150+
exists: bool = True,
151+
replace: bool = False,
152+
columns_to_types: t.Optional[t.Dict[str, exp.DataType]] = None,
153+
table_description: t.Optional[str] = None,
154+
column_descriptions: t.Optional[t.Dict[str, str]] = None,
155+
table_kind: t.Optional[str] = None,
156+
**kwargs: t.Any,
157+
) -> None:
158+
catalog = self.get_current_catalog()
159+
catalog_type_tuple = self.fetchone(
160+
exp.select("type")
161+
.from_("duckdb_databases()")
162+
.where(exp.column("database_name").eq(catalog))
163+
)
164+
catalog_type = catalog_type_tuple[0] if catalog_type_tuple else None
165+
166+
partitioned_by_exps = None
167+
if catalog_type == "ducklake":
168+
partitioned_by_exps = kwargs.pop("partitioned_by", None)
169+
170+
super()._create_table(
171+
table_name_or_schema,
172+
expression,
173+
exists,
174+
replace,
175+
columns_to_types,
176+
table_description,
177+
column_descriptions,
178+
table_kind,
179+
**kwargs,
180+
)
181+
182+
if partitioned_by_exps:
183+
# Schema object contains column definitions, so we extract Table
184+
table_name = (
185+
table_name_or_schema.this
186+
if isinstance(table_name_or_schema, exp.Schema)
187+
else table_name_or_schema
188+
)
189+
table_name_str = (
190+
table_name.sql(dialect=self.dialect)
191+
if isinstance(table_name, exp.Table)
192+
else table_name
193+
)
194+
partitioned_by_str = ", ".join(
195+
expr.sql(dialect=self.dialect) for expr in partitioned_by_exps
196+
)
197+
self.execute(f"ALTER TABLE {table_name_str} SET PARTITIONED BY ({partitioned_by_str});")

sqlmesh/core/linter/helpers.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,8 @@ def to_range(self, read_file: t.Optional[t.List[str]]) -> Range:
8484
)
8585

8686

87-
def read_range_from_file(file: Path, text_range: Range) -> str:
88-
"""
89-
Read the file and return the content within the specified range.
90-
91-
Args:
92-
file: Path to the file to read
93-
text_range: The range of text to extract
94-
95-
Returns:
96-
The content within the specified range
97-
"""
98-
with file.open("r", encoding="utf-8") as f:
99-
lines = f.readlines()
87+
def read_range_from_string(content: str, text_range: Range) -> str:
88+
lines = content.splitlines(keepends=False)
10089

10190
# Ensure the range is within bounds
10291
start_line = max(0, text_range.start.line)
@@ -116,6 +105,23 @@ def read_range_from_file(file: Path, text_range: Range) -> str:
116105
return "".join(result)
117106

118107

108+
def read_range_from_file(file: Path, text_range: Range) -> str:
109+
"""
110+
Read the file and return the content within the specified range.
111+
112+
Args:
113+
file: Path to the file to read
114+
text_range: The range of text to extract
115+
116+
Returns:
117+
The content within the specified range
118+
"""
119+
with file.open("r", encoding="utf-8") as f:
120+
lines = f.readlines()
121+
122+
return read_range_from_string("".join(lines), text_range)
123+
124+
119125
def get_range_of_model_block(
120126
sql: str,
121127
dialect: str,

sqlmesh/core/linter/rule.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import abc
44
from dataclasses import dataclass
5+
from pathlib import Path
56

67
from sqlmesh.core.model import Model
78

@@ -43,6 +44,7 @@ class Range:
4344
class TextEdit:
4445
"""A text edit to apply to a file."""
4546

47+
path: Path
4648
range: Range
4749
new_text: str
4850

0 commit comments

Comments
 (0)