Skip to content

fix(clickhouse): register table comments via command instead of inline CTAS - #6007

Merged
mday-io merged 1 commit into
SQLMesh:mainfrom
cookieark7:fix/clickhouse-ctas-table-comment
Sep 1, 2026
Merged

fix(clickhouse): register table comments via command instead of inline CTAS#6007
mday-io merged 1 commit into
SQLMesh:mainfrom
cookieark7:fix/clickhouse-ctas-table-comment

Conversation

@cookieark7

@cookieark7 cookieark7 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #5969.

ClickhouseEngineAdapter sets COMMENT_CREATION_VIEW but never COMMENT_CREATION_TABLE, so it falls back to the base default IN_SCHEMA_DEF_CTAS and embeds COMMENT '...' in CREATE TABLE ... AS SELECT, which Cloud rejects:

Code: 62. DB::Exception: Syntax error: failed at position 198 (COMMENT):
COMMENT 'test table description' AS SELECT ... Expected one of: AS, end of query.

Setting it to COMMENT_COMMAND_ONLY keeps the comment out of the CTAS and routes the table and column descriptions through the existing ALTER TABLE ... MODIFY COMMENT / ... COMMENT COLUMN paths, same as views already do.

Test Plan

Heads up: these tests only fail on Cloud. They pass against the Docker ClickHouse behind make clickhouse-test both before and after this change (I checked 24.7 and 26.8.1 — both accept the inline COMMENT), so I couldn't reproduce the Cloud failure locally.

What I could verify is that the CTAS no longer carries a COMMENT at all:

-- before
CREATE TABLE "t" ENGINE=MergeTree ORDER BY () AS (SELECT ...) COMMENT 'test table description'

-- after
CREATE TABLE "t" ENGINE=MergeTree ORDER BY () AS SELECT ...
ALTER TABLE "t" MODIFY COMMENT 'test table description'
ALTER TABLE "t" COMMENT COLUMN "id" 'test id column description'

Since the inline COMMENT is gone entirely, its position no longer matters. Leaving the actual Cloud confirmation to the clickhouse-cloud-test job here.

Locally: make clickhouse-test 168 passed, make fast-test 2621 passed, make style clean.

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable) — none added; the two existing tests in CI Fix - Clickhouse-Cloud CI Currently Failing #5969 cover it
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO

…e CTAS

ClickhouseEngineAdapter set COMMENT_CREATION_VIEW to COMMENT_COMMAND_ONLY but
never set COMMENT_CREATION_TABLE, so it silently inherited the EngineAdapter
default of IN_SCHEMA_DEF_CTAS. That default asserts the engine can embed
COMMENT '...' inside a CREATE TABLE ... AS SELECT, which ClickHouse Cloud
rejects with a syntax error (code 62, SYNTAX_ERROR).

Setting COMMENT_CREATION_TABLE to COMMENT_COMMAND_ONLY keeps the comment out
of the CTAS entirely and routes both the table description and the column
descriptions through the post-create ALTER TABLE ... MODIFY COMMENT and
ALTER TABLE ... COMMENT COLUMN paths, which the adapter already implements
and which views already rely on.

Fixes SQLMesh#5969

Signed-off-by: cookieark <aishwary.kantode@gmail.com>
@mday-io
mday-io self-requested a review September 1, 2026 13:21
@mday-io

mday-io commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Good find. Thanks - approving and merging.

@mday-io
mday-io merged commit 240471c into SQLMesh:main Sep 1, 2026
33 checks passed
@cookieark7

Copy link
Copy Markdown
Contributor Author

Welcome !

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.

CI Fix - Clickhouse-Cloud CI Currently Failing

2 participants