Fix DESCRIBE TABLE (...) AS ... syntax#100205
Conversation
|
The failures of They were introduced by #104690 ("Add #104690 was merged in violation of the ClickHouse team rules: its own CI already showed these two tests failing (10 times between May 12 and June 1) before it was merged. Please update your branch to pick up the revert; the tests should pass again. |
…Expression The previous guard `pos->type != TokenType::OpeningRoundBracket` diverted every parenthesized `DESCRIBE` source to `ParserTableExpression`, which consumes only the first `(SELECT ...)` and leaves any following set operator unparsed. This regressed valid queries such as `DESCRIBE (SELECT 1) UNION ALL (SELECT 2)`. Instead, speculatively parse a `SELECT` first and keep it only when it is a bare `SELECT` or a genuine set operation (more than one element). A lone parenthesized `SELECT` is rolled back so `ParserTableExpression` can pick up a trailing alias, fixing `DESCRIBE (SELECT 1) AS source` without breaking set operations. Extends test 04053_describe_subquery_alias with UNION ALL coverage for both parser branches. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Picked up this PR, merged the latest AI Review blocker (fixed in 0915825): the previous guard The parser now speculatively parses a Verified with a freshly built binary; the test output is byte-identical to the reference: CI: the only failures on the previous run were the |
The previous fix kept the speculative `SELECT` path whenever the parsed `ASTSelectWithUnionQuery` had more than one element in `list_of_selects`. But `ParserSelectWithUnionQuery` lifts up a single parenthesized inner union, so a lone parenthesized subquery whose body is a set operation, such as `DESCRIBE (SELECT 1 AS a UNION ALL SELECT 2) AS source`, also produces two elements. As a result it stayed on the `SELECT` path and the trailing `AS source` was left unconsumed, producing the same syntax error this pull request fixes. Disambiguate by inspecting what follows the parenthesis matching the leading `(` instead of the element count: keep the `SELECT` path only when that parenthesis is immediately followed by a set-operation keyword (`UNION`, `EXCEPT`, `INTERSECT`), i.e. a genuine top-level set operation like `(SELECT 1) UNION ALL (SELECT 2)`. A lone parenthesized subquery, even one whose body is a set operation, is rolled back to `ParserTableExpression` so the trailing alias is accepted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…uery-alias-fix Pick up the master fix for the 01951_distributed_push_down_limit and 01952_optimize_distributed_group_by_sharding_key Fast test (arm_darwin) failures, which were a master-wide transient regression (the distributed query plan EXPLAIN output changed ReadFromRemote into an inlined local plan) unrelated to this DESCRIBE parser change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Merged the latest The red checks on the previous run are all unrelated to this
AI Review verdict is ✅ Approve, there are no unresolved review threads, and coverage of the changed lines is 25/25 (100%). Re-running CI on a current |
Refresh CI: branch was 553 commits behind master and the previous run was red only on unrelated master-wide flakes (refreshable mat view integration test, arm_msan Hung check, BuzzHouse fault-injection harness). The PR code is unchanged - master touched none of the three DESCRIBE source files.
|
Merged the latest The previous run's failures are not caused by this PR:
AI Review is ✅ Approve, all review threads are resolved, and changed-line coverage is complete. The remaining blocker is a human approval. |
Refresh CI on the latest master. The previous run's only red was a job-level cancellation of the 'Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6)' shard: test_storage_iceberg_concurrent/test_concurrent_reads hung (the known-flaky test fixed by the merged #108075), which pushed the shard past its time budget and caused the operation to be canceled; the in-flight tests (test_huge_concurrent_restore, test_azure_disk_unreachable) were marked failed only because of that cancellation. This merge brings in #108075 (merged after the previous merge-base), which fixes the hang. The DESCRIBE parser code is unchanged - master touched none of the PR's three files, so the merge net diff vs master is exactly those files, byte-identical.
|
Merged the latest This merge is not just to refresh drift — it brings in a fix for the only red on the previous run. That run's sole failure was a job-level cancellation of AI Review is ✅ Approve, all review threads are resolved, and changed-line coverage is complete. The remaining blocker is a human approval. |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 25/25 (100.00%) | Lost baseline coverage: none · Uncovered code |

Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixes the case where an alias after a subquery in DESCRIBE TABLE is not accepted by the parser and results in a syntax error. Fixes #100031.
Documentation entry for user-facing changes
Version info
26.6.1.1195