Skip to content

Fix ClickHouse cluster CTAS execution - #5978

Open
0xhanh wants to merge 1 commit into
SQLMesh:mainfrom
0xhanh:main
Open

Fix ClickHouse cluster CTAS execution#5978
0xhanh wants to merge 1 commit into
SQLMesh:mainfrom
0xhanh:main

Conversation

@0xhanh

@0xhanh 0xhanh commented Aug 23, 2026

Copy link
Copy Markdown

Description

Fix ClickHouse CTAS behavior in cluster mode.

Cluster CTAS now follows the same two-step flow as ClickHouse Cloud:

  1. Create the table with EMPTY and ON CLUSTER.
  2. Run a single client-side INSERT ... SELECT.

This prevents ON CLUSTER ... AS SELECT from executing the source query on every cluster node and duplicating data. A regression test covers the generated cluster-mode SQL.

Test Plan

  • Ran .venv/bin/python -m pytest tests/core/engine_adapter/test_clickhouse.py -q — 35 passed.
  • Ran Ruff format and lint checks for the changed files.

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the [DCO](DCO)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant