refactor(core): correct the aliased-scan comments the shortcut invalidated - #2648
refactor(core): correct the aliased-scan comments the shortcut invalidated#2648goldmedal wants to merge 2 commits into
Conversation
…dated The pre-order SubqueryAlias -> TableScan shortcut left three comments describing the bottom-up path it replaced. - ModelSourceNode::new documented the wildcard-prune branch as triggered by a `count(*)` *or* the throwaway inner plan built for an aliased model scan. The shortcut deleted that second trigger: a wildcard is now only substituted when the scan reaches ModelPlanNodeBuilder with no required fields at all. This comment carries the column-level-security prune-vs-deny rationale, so a stale trigger list there is worth more than a normal comment fix. - analyze_subquery_alias_model's doc still said it rebuilds the nested ModelPlanNode shape; it rejects it. - analyze_model_internal's SubqueryAlias arm still explained itself in terms of the bottom-up rewrite that no longer reaches a model scan. Also name the invariant the internal_err! actually rests on. It is not that the shortcut intercepts every shape: it is that the only producer of a directly-nested SubqueryAlias, ExpandWrenViewRule, plans view bodies with SessionState::create_logical_plan (unoptimized), so a view body always has a Projection root and the inner node is never a bare TableScan. Written down so a change to view planning does not silently arm that branch. analyze_subquery_alias_model's three now-unused parameters go with it. No behavior change: comments plus a private signature. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe change simplifies nested model alias analysis after aliased table scans use the pre-order shortcut. It also clarifies wildcard expansion and inaccessible-column handling in ChangesModel analysis updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@core/wren-core/core/src/logical_plan/analyze/model_anlayze.rs`:
- Around line 450-458: Update the branch comment above the LogicalPlan match in
the model-analysis fallback to reflect the actual conditions:
analyze_subquery_alias_model rejects any Extension input, while its
non-ModelPlanNode path calls internal_err!, and the TableScan arm can still
receive MDL scans when get_model is absent and shortcut_aliased_table_scan
returns unchanged.
- Around line 787-805: Update the documentation for analyze_subquery_alias_model
to state that the non-Extension fallback flattens nested aliases by discarding
the inner alias and rebuilding the plan with the outer alias parameter. Keep the
existing Extension rejection behavior and implementation unchanged.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8ea47c17-ee7e-4a6e-ad37-b8f1bb13eb1b
📒 Files selected for processing (2)
core/wren-core/core/src/logical_plan/analyze/model_anlayze.rscore/wren-core/core/src/logical_plan/analyze/plan.rs
…attening The comment claimed the nested-alias arm rejects only an already-analyzed ModelPlanNode (it rejects any Extension) and that the TableScan arm sees only non-MDL tables (the shortcut also declines MDL tables that are not models). analyze_subquery_alias_model's doc claimed non-Extension inputs pass through unchanged; they are flattened onto the outer alias and the inner one is dropped. Addresses CodeRabbit's review. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Summary
Follow-up to #2612. That PR replaced the bottom-up rewrite of
SubqueryAlias -> TableScanwith a pre-order shortcut, but three comments still describe the path it removed. All three
sit on code a reader consults to understand behavior they cannot infer from the code alone,
so they are worth correcting rather than leaving to drift.
ModelSourceNode::new(plan.rs) documented the wildcard-prune branch as reached by"a
count(*), or the throwaway inner plan built for a model scan referenced with a tablealias". refactor(core): avoid throwaway ModelPlanNode build for aliased model scans #2612 deleted that second trigger. The wildcard is substituted in exactly one place
(
ModelPlanNodeBuilder::build, whenrequired_fields.is_empty()), so only thecount(*)-shaped case reaches it now. This comment carries the column-level-securityprune-vs-deny rationale from fix(core): prune inaccessible CLS columns in wildcard expansion instead of denying #2449, which is why a stale trigger list there matters more
than a normal stale comment.
analyze_subquery_alias_model's doc still opened with "Rebuilds aSubqueryAlias -> SubqueryAlias -> Extension -> ModelPlanNodeshape". It rejects thatshape now.
analyze_model_internal'sSubqueryAliasarm still explained itself as "because thebottom-up transformation is used, the table_scan is already transformed to the
ModelPlanNode before the SubqueryAlias" — which is what the shortcut stopped doing.
It also writes down the invariant the
internal_err!rests on. The existing message impliesthe branch is unreachable because the shortcut intercepts every shape; that is not quite the
reason. The shortcut only declines to fire on a directly nested
SubqueryAlias, and theone thing that produces that shape here is
ExpandWrenViewRule, which plans view bodies withSessionState::create_logical_plan— unoptimized. A view body therefore always has aProjectionroot, so the inner node is never a bareTableScan. That is a property of howviews are planned today, not something this rule owns, so it is now stated with a pointer to
revisit if view planning changes.
analyze_subquery_alias_model's three_-prefixed parameters, dead since #2612, go with it.What failure does this repair?
None. Comments plus one private signature; no plan, SQL, or public API changes.
How is it tested?
No new tests — there is no behavior to assert. The parameter removal is compiler-checked and
the rest is comments.
RUST_MIN_STACK=8388608 cargo test --lib --tests --bins— 149 passedcargo test -p wren-sqllogictest—tpch.slt,model.slt,view.slt,type.sltpasscargo clippy --all-targets --all-features -- -D warnings— cleancargo fmt --check— clean; working tree clean after the test runSeparately verified while reviewing #2612: 20 query shapes (view + alias, view
count(*),CTE with an outer alias, nested subquery alias, self-join, view-join-model,
IN/EXISTS/correlated-scalar subqueries,
UNION ALL, column aliases) produce byte-identical SQL againstthat PR's merge-base, and none of them reaches the
internal_err!branch.Not checked: whether any shape outside those 20 can form a directly-nested
SubqueryAlias -> SubqueryAlias -> TableScan. The claim above is structural, not exhaustive.Summary by CodeRabbit
Documentation
Refactor