Skip to content

Do not analyze viewExplain arguments before validation - #108384

Merged
cv4g merged 3 commits into
masterfrom
fix-view-explain-argument-analysis
Aug 31, 2026
Merged

cv4g merged 3 commits into
masterfrom
fix-view-explain-argument-analysis

Conversation

@cv4g

@cv4g cv4g commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

viewExplain is the internal lowered form of SELECT * FROM (EXPLAIN ...). Its arguments are consumed directly by TableFunctionExplain::parseArguments: the first two must be string literals and the optional third argument is the unresolved SELECT query being explained.

This change skips expression analysis for all viewExplain arguments so invalid arguments are rejected by parseArguments as BAD_ARGUMENTS instead of resolving nested expressions in arguments that should be validated as literal AST nodes.

Changelog category (leave one):

  • Bug Fix

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixes error handling for invalid calls to the internal viewExplain table function. If the EXPLAIN kind or serialized settings argument is not a string literal, ClickHouse now returns BAD_ARGUMENTS instead of analyzing the invalid expression and potentially returning an unrelated error such as UNKNOWN_TABLE.


Workflow [PR]
Sync PR [sync-upstream/pr/108384]

Version info

  • Merged into: 26.9.1.442 (included in 26.9 and later)

@clickhouse-gh

clickhouse-gh Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f1cd36d]

Summary: ✅


AI Review

Summary

This PR changes viewExplain so the analyzer no longer resolves any of its arguments before TableFunctionExplain::parseArguments validates their raw AST shapes. That matches how the subquery rewrite constructs viewExplain, fixes the bad diagnostic path described in the PR, and the added stateless cases cover the regression where invalid first or second arguments were analyzed before being rejected.

Final Verdict

✅ No material issues found in the current diff.

LLVM Coverage Report

Measured on commit f1cd36d.

Metric Baseline Current Δ
Lines 88.60% 88.60% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 80.90% 80.90% +0.00%

Changed lines: Changed C/C++ lines covered: 7/7 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jun 24, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.50% 85.30% -0.20%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.50% -0.10%

Changed lines: Changed C/C++ lines covered by tests: 7/7 (100.00%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@groeneai groeneai mentioned this pull request Jul 1, 2026
1 task done
@clickhouse-gh

clickhouse-gh Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing f1cd36d79 with master bb113c384 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of d469feea5; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 9 s compile time in total, 7 of them have a recent master baseline.

Job report

@vdimir vdimir self-assigned this Aug 31, 2026

@vdimir vdimir left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may still want to add a changelog entry since it changes behavior, something like "Return BAD_ARGUMENTS error code for illegal viewExplain argument order instead of previously ..."

@cv4g
cv4g added this pull request to the merge queue Aug 31, 2026
Merged via the queue into master with commit 28faa53 Aug 31, 2026
175 checks passed
@cv4g
cv4g deleted the fix-view-explain-argument-analysis branch August 31, 2026 14:14
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants