Skip to content

Commit 4178672

Browse files
authored
Merge branch 'main' into lint-model-paths
2 parents 2660fc6 + 1dcd885 commit 4178672

56 files changed

Lines changed: 4290 additions & 563 deletions

Some content is hidden

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

‎.github/dependabot.yml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@ updates:
44
directory: '/'
55
schedule:
66
interval: 'weekly'
7+
groups:
8+
# Storybook add-ons declare a peer dependency on the matching `storybook`
9+
# release, so they have to move together. Bump them in a single PR.
10+
storybook:
11+
patterns:
12+
- 'storybook'
13+
- '@storybook/*'
14+
- '@chromatic-com/storybook'
15+
- 'eslint-plugin-storybook'
16+
update-types:
17+
- 'minor'
18+
- 'patch'
19+
ignore:
20+
# A Storybook major upgrade has to be done by hand as one coordinated
21+
# migration (e.g. @storybook/addon-vitest 10 requires vitest 4+), so don't
22+
# open per-package major-bump PRs, which break the Storybook build.
23+
- dependency-name: 'storybook'
24+
update-types: ['version-update:semver-major']
25+
- dependency-name: '@storybook/*'
26+
update-types: ['version-update:semver-major']
27+
- dependency-name: '@chromatic-com/storybook'
28+
update-types: ['version-update:semver-major']
29+
- dependency-name: 'eslint-plugin-storybook'
30+
update-types: ['version-update:semver-major']
731
- package-ecosystem: 'github-actions'
832
directory: '/'
933
schedule:

‎.github/workflows/pr.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ jobs:
150150
. ./venv/Scripts/activate
151151
python.exe -m pip install --upgrade pip
152152
make install-dev
153+
- name: Install DuckLake extension
154+
run: |
155+
. ./venv/Scripts/activate
156+
python -c "import duckdb; duckdb.connect().install_extension('ducklake')"
153157
- name: Run fast unit tests
154158
run: |
155159
. ./venv/Scripts/activate
@@ -267,6 +271,7 @@ jobs:
267271
trino,
268272
spark,
269273
clickhouse,
274+
clickhouse-datalake,
270275
risingwave,
271276
starrocks,
272277
]
@@ -293,6 +298,9 @@ jobs:
293298
run: |
294299
source .venv/bin/activate
295300
make ${{ matrix.engine }}-test
301+
- name: Stop DataLake services
302+
if: ${{ always() && matrix.engine == 'clickhouse-datalake' }}
303+
run: make clickhouse-datalake-down
296304
- name: Upload test results
297305
uses: actions/upload-artifact@v7
298306
if: ${{ !cancelled() }}

‎.github/workflows/release.yaml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ jobs:
4040
- name: Set up Python
4141
uses: actions/setup-python@v7
4242
with:
43-
python-version: '3.10'
43+
# 3.13.17+ bundles pip 26.2.2+, which no longer trusts the compromised eMudhra/emSign root CA.
44+
python-version: '3.13'
4445
- name: Install uv
4546
uses: astral-sh/setup-uv@v7
47+
- name: Check pip includes the eMudhra/emSign CA removal
48+
run: |
49+
python -c "import sys, pip; v = tuple(int(p) for p in pip.__version__.split('.')[:3]); sys.exit(0 if v >= (26, 2, 2) else f'pip {pip.__version__} predates the eMudhra/emSign CA removal; need >= 26.2.2')"
4650
- name: Install build dependencies
4751
run: pip install build twine setuptools_scm
4852
- name: Publish Python package

‎Makefile‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.PHONY: docs
2+
.PHONY: clickhouse-datalake-up clickhouse-datalake-test clickhouse-datalake-down
23

34
ifdef UV
45
PIP := uv pip
@@ -192,6 +193,21 @@ engine-%-up: engine-%-install engine-docker-%-up
192193
engine-%-down:
193194
docker compose -f ./tests/core/engine_adapter/integration/docker/compose.${*}.yaml down -v
194195

196+
CLICKHOUSE_DATALAKE_COMPOSE = docker compose --project-name sqlmesh-clickhouse-datalake -f ./tests/core/engine_adapter/integration/docker/compose.clickhouse-datalake.yaml
197+
198+
clickhouse-datalake-up:
199+
$(CLICKHOUSE_DATALAKE_COMPOSE) up -d --wait --wait-timeout 120 clickhouse minio-init rest
200+
$(CLICKHOUSE_DATALAKE_COMPOSE) run --build --rm seed
201+
202+
clickhouse-datalake-test:
203+
docker info >/dev/null
204+
$(MAKE) engine-clickhouse-install
205+
$(MAKE) clickhouse-datalake-up
206+
SQLMESH_RUN_CLICKHOUSE_DATALAKE=1 pytest -n 0 -m "docker and clickhouse_datalake" tests/core/engine_adapter/integration/test_integration_clickhouse_datalake.py --junitxml=test-results/junit-clickhouse-datalake.xml
207+
208+
clickhouse-datalake-down:
209+
$(CLICKHOUSE_DATALAKE_COMPOSE) down -v --remove-orphans
210+
195211
##################
196212
# Docker Engines #
197213
##################

‎docs/concepts/audits.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ MODEL (
477477
#### valid_uuid, valid_uuid_non_blocking
478478
Ensures that all non-NULL rows of a column contain a string with the UUID structure.
479479

480-
UUID structure determined by matching regular expression `'^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'`.
480+
UUID structure determined by matching regular expression `'^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'`.
481481

482482
This example asserts that all `uuid` values have the UUID structure:
483483

‎docs/guides/configuration.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,10 +1213,12 @@ Example configuration:
12131213

12141214
#### Default connections/scheduler
12151215

1216-
The `default_connection`, `default_test_connection`, and `default_scheduler` keys are used to specify shared defaults across multiple gateways.
1216+
The `default_connection`, `default_test_connection`, and `default_scheduler` keys specify a connection or scheduler for gateways that do not define their own.
12171217

12181218
For example, you might have a specific connection where your tests should run regardless of which gateway is being used. Instead of duplicating the test connection information in each gateway specification, specify it once in the `default_test_connection` key.
12191219

1220+
A default is only used when a gateway omits the corresponding key entirely. If a gateway specifies its own `connection`, `test_connection`, or `scheduler`, SQLMesh uses that configuration as written and ignores the default. Fields are not merged, so a gateway connection cannot inherit individual fields such as `type` from `default_connection`. Each gateway connection must be a complete connection configuration.
1221+
12201222
Example configuration specifying a Postgres default connection, in-memory DuckDB default test connection, and builtin default scheduler:
12211223

12221224
=== "YAML"

‎docs/integrations/engines/clickhouse.md‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,57 @@ gateways:
470470

471471
With this configuration, ClickHouse models will appear as `ch_virtual.mydb.mytable` in plan output instead of `__clickhouse__.mydb.mytable`.
472472

473+
### Reading catalog-backed physical tables
474+
475+
When ClickHouse exposes a source catalog through a [`DataLakeCatalog`](https://clickhouse.com/docs/engines/database-engines/datalake), map that source catalog to its ClickHouse database in the connection configuration:
476+
477+
```yaml
478+
gateways:
479+
clickhouse:
480+
connection:
481+
type: clickhouse
482+
host: my-clickhouse-host
483+
username: default
484+
datalake_catalog_mapping:
485+
lake: iceberg
486+
```
487+
488+
SQLMesh renders `lake.analytics.orders` as `iceberg."analytics.orders"`. It combines the source
489+
schema and table into one quoted table name because ClickHouse uses a two-level namespace. The
490+
`iceberg` database must already exist and use the `DataLakeCatalog` engine. SQLMesh does not create
491+
the database or manage its metastore or storage permissions.
492+
493+
For parsed queries that read data without writing the result to a ClickHouse table, SQLMesh rewrites
494+
mapped source catalogs and passes other foreign catalog-qualified references through unchanged.
495+
During rendering, SQLMesh strips the configured virtual catalog prefix, even before injection. For
496+
`INSERT ... SELECT` and other query materializations, SQLMesh rewrites mapped sources and validates
497+
the remaining catalog-qualified sources. With a non-empty mapping, each source catalog must appear
498+
in the mapping. When SQLMesh has injected a virtual catalog, a source can also use that catalog.
499+
SQLMesh raises an error for other catalogs. Without a non-empty mapping or an injected virtual
500+
catalog, SQLMesh does not apply DataLake mapping or catalog validation during materialization.
501+
502+
This mapping rewrites parsed query sources. It does not rewrite table names used for metadata
503+
operations such as `columns()` or `table_exists()`. The `sqlmesh create_external_models` command also
504+
uses the source name as supplied when it fetches column types, so it cannot infer columns for a
505+
source named `lake.analytics.orders` through the mapping. In a ClickHouse-only project, registering
506+
that three-part logical name as an external model can also fail SQLMesh's schema nesting check,
507+
because ClickHouse project models use two-part names.
508+
509+
To register column metadata until mapped names are supported there, use ClickHouse's physical
510+
two-part name in both the external model and the query. For example, use
511+
`iceberg."analytics.orders"` for the table exposed by database `iceberg`. This matches ClickHouse's
512+
`database."schema.table"` name and keeps the model at ClickHouse's two-part nesting level. The
513+
mapping still lets SQLMesh render queries that use mapped logical names. Without registered
514+
column metadata, SQLMesh cannot fully optimize those queries or produce column-level lineage.
515+
516+
An injected virtual catalog takes precedence over a mapping key with the same name. SQLMesh treats
517+
that name as its virtual catalog. Use different names for the virtual catalog and DataLakeCatalog
518+
source catalogs. The mapping applies to query source references. It does not rewrite SQL strings
519+
passed directly to the ClickHouse adapter or map `INSERT` targets.
520+
521+
View creation rejects a source that uses another catalog when a virtual catalog is injected, even
522+
if the mapping includes that source. Mapped-source views work when no virtual catalog is injected.
523+
473524
## Local/Built-in Scheduler
474525

475526
**Engine Adapter Type**: `clickhouse`
@@ -498,3 +549,4 @@ With this configuration, ClickHouse models will appear as `ch_virtual.mydb.mytab
498549
| `connection_settings` | Additional [connection settings](https://clickhouse.com/docs/integrations/python#settings-argument) | dict | N |
499550
| `connection_pool_options` | Additional [options](https://clickhouse.com/docs/integrations/python#customizing-the-http-connection-pool) for the HTTP connection pool | dict | N |
500551
| `virtual_catalog` | Override the virtual catalog name used when ClickHouse runs alongside a catalog-aware gateway (e.g. Trino). Defaults to `__{gateway_name}__`. See [Multi-gateway setup](#multi-gateway-setup) for details. | string | N |
552+
| `datalake_catalog_mapping` | Map source catalogs to ClickHouse DataLakeCatalog databases. See [Reading catalog-backed physical tables](#reading-catalog-backed-physical-tables). | dict | N |

‎docs/reference/configuration.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,15 @@ If a configuration contains multiple gateways, SQLMesh will use the first one in
264264

265265
### Default connections/scheduler
266266

267-
The `default_connection`, `default_test_connection`, and `default_scheduler` keys are used to specify shared defaults across multiple gateways.
267+
The `default_connection`, `default_test_connection`, and `default_scheduler` keys specify a connection or scheduler for gateways that do not define their own.
268268

269269
For example, you might have a specific connection where your tests should run regardless of which gateway is being used. Instead of duplicating the test connection information in each gateway specification, specify it once in the `default_test_connection` key.
270270

271+
A default is only used when a gateway omits the corresponding key entirely. If a gateway specifies its own `connection`, `test_connection`, or `scheduler`, SQLMesh uses that configuration as written and ignores the default. Fields are not merged, so a gateway connection cannot inherit individual fields such as `type` from `default_connection`.
272+
271273
| Option | Description | Type | Required |
272274
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | :---------: | :------: |
273-
| `default_connection` | The default connection to use if one is not specified in a gateway (Default: A DuckDB connection that creates an in-memory database) | connection | N |
275+
| `default_connection` | The connection to use for any gateway that does not specify a `connection` | connection | N |
274276
| `default_test_connection` | The default connection to use when running tests if one is not specified in a gateway (Default: A DuckDB connection that creates an in-memory database) | connection | N |
275277
| `default_scheduler` | The default scheduler configuration to use if one is not specified in a gateway (Default: built-in scheduler) | scheduler | N |
276278

0 commit comments

Comments
 (0)