Repository navigation
Conversation
b60d212 to
c97eba3
Compare
|
Workflow [PR], commit [6195da1] Summary: ⏳
AI ReviewSummaryThis PR fixes Final VerdictStatus: ✅ Approve |
aefafe2 to
a3857d0
Compare
|
Looks like the tests failing are unrelated to the changes in this PR |
2b8177c to
8e56e72
Compare
|
@nihalzp since you added the tag to be tested, do you think this PR is ready to be reviewed? Any major concerns? |
8e56e72 to
e13dd5c
Compare
e13dd5c to
d58ba67
Compare
`EXPLAIN SYNTAX` rewrote `SELECT t.number FROM my_pv(n=1) AS t` into a subquery aliased with the view's table name (`AS my_pv`), which made analyzer-path resolution fail with an unknown identifier exception for the still-present `t.number` reference. Use the original table function alias when present, falling back to the view name only if no alias was provided. Adds a regression test for the aliased case.
8ff075b to
121b519
Compare
When a parameterized view shadows a built-in table function name (e.g. a user view named `numbers`), `EXPLAIN SYNTAX` was expanding the view while regular execution correctly resolved the built-in table function, producing inconsistent behaviour (and an `UNKNOWN_QUERY_PARAMETER` exception when the view's parameters were not supplied). Match `QueryAnalyzer::resolveTableFunction` by checking `TableFunctionFactory` first and skipping view expansion when the name is a registered table function.
A parameterized view called with FINAL or SAMPLE executes correctly at run
time, but the EXPLAIN SYNTAX rewrite turned the call into a subquery while
leaving the modifiers on the table expression, which produced
UNSUPPORTED_METHOD ("Table expression modifiers ... are not supported for
subquery") for valid queries.
Skip the expansion when these modifiers are present so EXPLAIN SYNTAX
prints the original form, which is non lossy and matches what execution
accepts.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 7b1012c. Configure here.
The earlier commits added three EXPLAIN SYNTAX cases (builtin shadowing, FINAL, SAMPLE) but only updated the new analyzer reference file, so the test would mismatch under the old analyzer. Add the corresponding output to the old analyzer reference. Pin the builtin shadowing case to the new analyzer with `SETTINGS allow_experimental_analyzer = 1` because the old analyzer cannot resolve that precedence even at execution time (pre-existing limitation), so the test stays meaningful in both modes.
For parameterized views declared with `SQL SECURITY DEFINER` or `NONE`, execution resolves inner tables under an overridden context. Inlining the view in `EXPLAIN SYNTAX` instead re-analyzes the inner query under the invoker's context, which fails with `ACCESS_DENIED` for users that can query the view but not its inner tables. Leave the original parameterized call intact in that case. Also clarify the `ExpandParameterizedViewsMatcher` comment: in the legacy path it complements `ExplainAnalyzedSyntaxMatcher` rather than being redundant, since `StorageView::replaceWithSubquery` only rewrites the first table expression and leaves JOIN sides untouched. Co-Authored-By: Claude Opus 4.7 <[email protected]>
…iews-103249' into fix-explain-syntax-parameterized-views-103249
Note explicitly that the FINAL/SAMPLE and SQL SECURITY guards live in the new analyzer rewrite (`ExpandParameterizedViewsMatcher`). The legacy path goes through `ExplainAnalyzedSyntaxMatcher` and `StorageView::replaceWithSubquery`, which is pre-existing behavior captured in `.oldanalyzer.reference`. Co-Authored-By: Claude Opus 4.7 <[email protected]>
LLVM Coverage Report
Changed lines: 83.93% (47/56) · Uncovered code |
|
The CI test that is timing out is unrelated to this PR. Should be addressed in #102207 |
628fc12

Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
EXPLAIN SYNTAX expands Parameterized Views
Closes #103249
Documentation entry for user-facing changes
Note
Medium Risk
Changes
EXPLAIN SYNTAXrewriting to consult the catalog and replace parameterized-view calls with inlined subqueries, which could affect query formatting/aliasing and edge-case resolution (e.g., shadowing table functions, FINAL/SAMPLE modifiers). Scope is limited to explain-time AST transformation and related tests.Overview
Fixes
EXPLAIN SYNTAXto inline parameterized view calls by rewritingFROM/JOIN view(args…)table-function syntax into the view’s parameter-substituted inner SELECT (as a subquery) before printing.The rewrite preserves explicit aliases, avoids expanding when
FINAL/SAMPLEmodifiers are present, and skips expansion when the name matches a registered table function (to match execution precedence). Tests are updated and a new stateless test is added to cover basic, nested, join, alias, shadowing, and modifier cases.Reviewed by Cursor Bugbot for commit 88a454c. Bugbot is set up for automated code reviews on this repo. Configure here.
Version info
26.6.1.198