Skip to content

fix(clickhouse): parse SHOW and EXPLAIN without command fallback#7563

Open
RedZapdos123 wants to merge 1 commit intotobymao:mainfrom
RedZapdos123:fix-clickhouse-show-explain-7548
Open

fix(clickhouse): parse SHOW and EXPLAIN without command fallback#7563
RedZapdos123 wants to merge 1 commit intotobymao:mainfrom
RedZapdos123:fix-clickhouse-show-explain-7548

Conversation

@RedZapdos123
Copy link
Copy Markdown
Contributor

@RedZapdos123 RedZapdos123 commented Apr 25, 2026

Description:

Issue #7548 reported that ClickHouse SHOW and EXPLAIN statements were parsed as Command fallback nodes, which made them indistinguishable from unknown/unsafe commands.

This PR updates the ClickHouse dialect to:

  • parse SHOW TABLES and SHOW CREATE TABLE ... as exp.Show
  • parse EXPLAIN ... and EXPLAIN ESTIMATE ... as non-Command AST nodes (exp.Describe with kind=EXPLAIN)
  • generate ClickHouse SQL for these ASTs so round-trip behavior is preserved

It also adds regression tests that cover the reported statements.

Closes #7548.

Checklist:

  • I have reviewed all changes in this PR myself.
  • I have added relevant regression test cases for this fix.
  • I have run linting and formatting checks in WSL using python -m ruff check sqlglot/dialects/clickhouse.py sqlglot/parsers/clickhouse.py sqlglot/generators/clickhouse.py tests/dialects/test_clickhouse.py and python -m ruff format --check sqlglot/dialects/clickhouse.py sqlglot/parsers/clickhouse.py sqlglot/generators/clickhouse.py tests/dialects/test_clickhouse.py.
  • I have run focused tests in WSL using python -m unittest tests.dialects.test_clickhouse.

The validation screenshot of the tests run, locally on WSL:

image image

Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
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.

ClickHouse dialect: SHOW and EXPLAIN parse as Command (fallback for unknown syntax)

2 participants