Skip to content

planner/core: fix redundant USING-column binding in ALL subquery - #66273

Merged
ti-chi-bot[bot] merged 16 commits into
pingcap:masterfrom
hawkingrei:fix-66272-join-using-missing-column
Mar 10, 2026
Merged

planner/core: fix redundant USING-column binding in ALL subquery#66273
ti-chi-bot[bot] merged 16 commits into
pingcap:masterfrom
hawkingrei:fix-66272-join-using-missing-column

Conversation

@hawkingrei

@hawkingrei hawkingrei commented Feb 14, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #66272

Problem Summary:

JOIN ... USING / NATURAL JOIN keeps two different column views in the planner:

  • FullSchema / FullNames are used for name resolution and still contain the redundant side of common columns.
  • Join.Schema() / OutputNames() are the executable join outputs and only keep the canonical visible column.

Because of that split, a qualified predicate such as t3.id = 10 could be resolved from FullSchema, but the resolved redundant column was not present in Join.Schema() anymore. The planner then carried that redundant column into later optimization, and physical ResolveIndices finally failed with a missing-column error.

The original repro is a JOIN ... USING query with a qualified predicate and = ALL (subquery):

SELECT /* issue:66272 */ id AS t0_id
FROM t1 JOIN t3 USING (id)
WHERE (((t3.right_v = 749) AND (t3.id = 10)) AND (t1.left_v = 93))
  AND (t3.right_v = ALL (SELECT t3.right_v AS c0 FROM t3 WHERE t3.right_v = 749));

This could fail with:

Can't find column test.t3.id in schema Column: [test.t1.id] ...

Follow-up review also showed that the fix must preserve several correctness constraints:

  • do not change derived-column behavior (NATURAL JOIN with view columns),
  • do not mislabel projection metadata for SELECT t_right.col,
  • do not silently change predicate semantics for mixed-type USING columns,
  • do not apply the same remap blindly to outer joins or DML paths.

What changed and how does it work?

  • Record redundant-column mappings during USING / NATURAL JOIN construction.
    • LogicalJoin now stores redundant column -> canonical visible output mappings when common columns are coalesced.
  • Remap redundant qualified base-table columns during predicate resolution instead of letting them leak into later phases.
    • In expression_rewriter, WHERE / HAVING remap a redundant column to the canonical join output only when:
      • the column comes from a base table (OrigTblName != ""),
      • the mapping comes from an inner USING / NATURAL JOIN,
      • the redundant column and the visible output column have identical RetType.
    • In havingWindowAndOrderbyExprResolver, apply the same idea for ORDER BY / HAVING name resolution.
  • Keep projection identity separate from predicate remapping.
    • findColFromNaturalUsingJoin keeps reading the original redundant-side identity from FullSchema / FullNames, so SELECT t3.id FROM t1 JOIN t3 USING(id) still reports t3 in result-field metadata.
  • Keep DML and outer-join behavior safe.
    • Skip redundant-column remap for UPDATE / DELETE.
    • Only allow remap for inner joins; outer joins keep original side semantics.

Cases and Fixes

Case Expected behavior How this PR handles it
JOIN ... USING + qualified predicate + = ALL (subquery) Do not carry redundant t3.id into physical planning Remap the redundant qualified base-table column to the canonical join output during predicate resolution
SELECT t3.id FROM t1 JOIN t3 USING(id) Result-field metadata should still report t3 Keep projection naming from FullSchema / FullNames; do not reuse predicate remap for select-list metadata
NATURAL JOIN with a view / derived column Do not rewrite derived-column semantics Only remap base-table columns with OrigTblName != ""
Mixed-type USING(id) such as VARCHAR vs INT Do not silently change predicate semantics Only remap when redundant and visible columns have identical RetType
LEFT JOIN / RIGHT JOIN with null-preserving semantics Preserve original outer-join behavior Only allow redundant-column remap for inner joins
UPDATE / DELETE ... USING(id) Keep DML binding behavior unchanged Skip redundant-column remap in DML builder paths

Cases covered by regression tests

  • Original JOIN ... USING + qualified predicate + = ALL (subquery) missing-column repro
  • Nested join with qualified redundant-column predicates
  • HAVING and ORDER BY on qualified redundant columns
  • Derived-column regression: NATURAL JOIN with a view column must not be remapped
  • Projection metadata regression: SELECT t3.id FROM t1 JOIN t3 USING(id) must still report t3
  • Mixed-type VARCHAR / INT USING(id) must remain type-safe
  • UPDATE / DELETE with USING
  • LEFT JOIN / RIGHT JOIN null-side semantics remain unchanged

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Test commands:

  • /Users/weizhenwang/.gvm/gos/go1.25.7/bin/go test -run '^TestSchemaCannotFindColumnRegression$' --tags=intest ./pkg/planner/core/casetest/schema
  • /Users/weizhenwang/.gvm/gos/go1.25.7/bin/go test -run 'TestJoinRegression/on' --tags=intest ./pkg/planner/core/casetest/join

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Fix planner missing-column errors for qualified redundant columns in `JOIN ... USING` / `NATURAL JOIN` queries.

@ti-chi-bot ti-chi-bot Bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Feb 14, 2026
@pantheon-ai

pantheon-ai Bot commented Feb 14, 2026

Copy link
Copy Markdown

This PR fixes a planner failure with JOIN ... USING + qualified predicate + = ALL (subquery) where a redundant USING-column (t3.id) could leak into later optimization and cause ResolveIndices to error with “Can’t find column…”. It remaps redundant columns from natural/using inner joins to the visible equivalent join output column during WHERE/HAVING rewrite, extends the join lookup/mapping helpers, and adds a regression test (join-using-compare-all-missing-column).

Open in Web
Learn more about Pantheon AI

@ti-chi-bot ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/planner SIG: Planner labels Feb 14, 2026

@pantheon-ai pantheon-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Code looks good. No issues found.

@codecov

codecov Bot commented Feb 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.58559% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.5035%. Comparing base (e383150) to head (cd609ad).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #66273        +/-   ##
================================================
- Coverage   77.6677%   77.5035%   -0.1642%     
================================================
  Files          2008       1930        -78     
  Lines        549877     538707     -11170     
================================================
- Hits         427077     417517      -9560     
- Misses       121092     121181        +89     
+ Partials       1708          9      -1699     
Flag Coverage Δ
integration 41.2538% <66.6666%> (-6.9337%) ⬇️
unit 76.6619% <85.5855%> (+0.4300%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 56.7974% <ø> (ø)
parser ∅ <ø> (∅)
br 48.7931% <ø> (-12.0952%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai

coderabbitai Bot commented Feb 27, 2026

Copy link
Copy Markdown

Important

Review skipped

This PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1c8417fd-c0be-496e-9eb3-b33c7ca1a347

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

Adds plan-scoped tracking and resolution for redundant columns produced by NATURAL/USING joins, applies remapping during name-resolution and expression rewriting, exposes LogicalJoin APIs to register/resolve mappings, and adds new schema regression tests and a Bazel go_test target; plus a minor test formatting tweak.

Changes

Cohort / File(s) Summary
Planner: expression rewriting
pkg/planner/core/expression_rewriter.go
Add plan-aware resolver resolveRedundantColumnFromNaturalUsingJoinPlan and apply redundant-column remapping in toColumn/name-resolution and expression rewriting paths.
Planner: logical plan builder
pkg/planner/core/logical_plan_builder.go
Collect redundant column mapping pairs during coalescing and register them on join nodes; use ResolveRedundantColumn when resolving names for ORDER BY / HAVING and natural/using join cases.
Operator: logical join
pkg/planner/core/operator/logicalop/logical_join.go
Add exported field RedundantColsToOutputIdx and methods RegisterRedundantColumnMapping and ResolveRedundantColumn to store and resolve redundant→visible column mappings on LogicalJoin.
Tests: schema casetest package
pkg/planner/core/casetest/schema/BUILD.bazel, pkg/planner/core/casetest/schema/main_test.go, pkg/planner/core/casetest/schema/cannot_find_column_test.go, pkg/planner/core/casetest/schema/testdata/*
Add Bazel go_test target schema_test, TestMain with goleak setup, a new regression test TestSchemaCannotFindColumnRegression, and accompanying testdata JSON files (in/out/xut).
Minor test tweak
pkg/planner/core/casetest/join/join_test.go
Remove an empty blank line in TestJoinRegression (non-functional formatting change).

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Parser
    participant LogicalPlanBuilder
    participant LogicalJoin
    participant ExprRewriter

    Client->>Parser: submit SQL
    Parser->>LogicalPlanBuilder: build logical plan (includes JOIN nodes)
    LogicalPlanBuilder->>LogicalJoin: RegisterRedundantColumnMapping(redundant, visible)
    LogicalJoin-->>LogicalPlanBuilder: store mapping
    LogicalPlanBuilder->>ExprRewriter: request name-resolution for WHERE/ORDER/HAVING
    ExprRewriter->>LogicalJoin: ResolveRedundantColumn(col)
    LogicalJoin-->>ExprRewriter: return canonical column + FieldName (if mapped)
    ExprRewriter->>LogicalPlanBuilder: emit resolved ColumnNameEx
    LogicalPlanBuilder-->>Client: final plan
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • solotzg
  • lcwangchao
  • xzhangxian1008

Poem

🐰 I hopped through joins where shadowed names once played,
I mapped the echoes so predicates won't fade.
Tests nibble crumbs and plans now show the way,
A tiny hop fixed confusion for the day.
🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'planner/core: fix redundant USING-column binding in ALL subquery' clearly and specifically describes the main change—fixing a planner bug related to redundant columns in USING joins within subqueries.
Linked Issues check ✅ Passed The changes address all coding requirements from issue #66272: remapping redundant columns in WHERE/HAVING contexts for USING joins, extending natural/using-join helpers, making argument extraction BCE-friendly, and adding regression tests in a dedicated schema casetest package.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the redundant column binding issue: expression rewriter adjustments for WHERE/HAVING, logical join modifications, test infrastructure, and test data files. No unrelated refactoring or feature additions are present.
Description check ✅ Passed The PR description is comprehensive and well-structured, following the template with all major sections completed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@hawkingrei

Copy link
Copy Markdown
Contributor Author

@pantheon-bot review

@pantheon-ai

pantheon-ai Bot commented Feb 27, 2026

Copy link
Copy Markdown

Review Complete

Findings: 1 issues
Posted: 1
Duplicates/Skipped: 0

@hawkingrei

Copy link
Copy Markdown
Contributor Author

/retest

@ti-chi-bot ti-chi-bot Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 27, 2026
@hawkingrei
hawkingrei force-pushed the fix-66272-join-using-missing-column branch from fba27ce to 9a3aa19 Compare February 27, 2026 10:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/planner/core/expression_rewriter.go`:
- Around line 2691-2698: The current logic in
resolveRedundantColumnFromNaturalUsingJoinPlan stops traversal whenever an
ancestor join's FullSchema contains col by immediately returning
x.ResolveRedundantColumn(col), which can prematurely return nil if that ancestor
has no mapping; instead, call x.ResolveRedundantColumn(col) and inspect its
result, and only return if a non-nil mappedCol (or non-empty mappedName) is
produced; otherwise continue iterating over x.Children() to let descendant joins
provide the actual mapping. Keep references to x.FullSchema,
x.ResolveRedundantColumn(col),
resolveRedundantColumnFromNaturalUsingJoinPlan(child, col), and x.Children() to
locate and implement the conditional check.

In `@pkg/planner/core/logical_plan_builder.go`:
- Around line 920-922: coalesceCommonColumns currently registers mappings via
p.RegisterRedundantColumnMapping using redundantColMappings too early, before
buildUsingClause/buildNaturalJoin may overwrite p.Schema()/OutputNames for
UPDATE/DELETE; move or defer registering these redundant column mappings until
after buildUsingClause and buildNaturalJoin (or any code path that mutates
p.Schema()/OutputNames for UPDATE/DELETE) so stored output indices are computed
against the final schema/output names; alternatively, conditionally skip
registration when the planner is in an UPDATE/DELETE path and perform
registration once the schema/output names are stabilized.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fba27ce and 9a3aa19.

📒 Files selected for processing (10)
  • pkg/planner/core/casetest/join/join_test.go
  • pkg/planner/core/casetest/schema/BUILD.bazel
  • pkg/planner/core/casetest/schema/cannot_find_column_test.go
  • pkg/planner/core/casetest/schema/main_test.go
  • pkg/planner/core/casetest/schema/testdata/cannot_find_column_suite_in.json
  • pkg/planner/core/casetest/schema/testdata/cannot_find_column_suite_out.json
  • pkg/planner/core/casetest/schema/testdata/cannot_find_column_suite_xut.json
  • pkg/planner/core/expression_rewriter.go
  • pkg/planner/core/logical_plan_builder.go
  • pkg/planner/core/operator/logicalop/logical_join.go
💤 Files with no reviewable changes (1)
  • pkg/planner/core/casetest/join/join_test.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • pkg/planner/core/casetest/schema/testdata/cannot_find_column_suite_xut.json
  • pkg/planner/core/casetest/schema/cannot_find_column_test.go
  • pkg/planner/core/casetest/schema/testdata/cannot_find_column_suite_out.json
  • pkg/planner/core/casetest/schema/main_test.go
  • pkg/planner/core/casetest/schema/testdata/cannot_find_column_suite_in.json

Comment thread pkg/planner/core/expression_rewriter.go Outdated
Comment thread pkg/planner/core/logical_plan_builder.go Outdated
Comment thread pkg/planner/core/expression_rewriter.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/planner/core/expression_rewriter.go (1)

2573-2704: ⚠️ Potential issue | 🟡 Minor

Please include targeted planner test evidence for this planner-core change.

Given this modifies planner name resolution/remapping, please add the exact targeted go test -run ... -tags=intest,deadlock command(s) and whether any rule testdata updates were needed.

As per coding guidelines pkg/planner/**: Run targeted planner unit tests (go test -run <TestName> -tags=intest,deadlock) and update rule testdata when needed for changes to planner rules or logical/physical plans.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/planner/core/expression_rewriter.go` around lines 2573 - 2704, Add
targeted planner unit tests that cover name-resolution and remapping around JOIN
... USING/NATURAL by exercising the modified functions toColumn,
findFieldNameFromNaturalUsingJoin, and
resolveRedundantColumnFromNaturalUsingJoinPlan; run the tests with the exact
commands: go test ./pkg/planner -run TestExpressionRewriter
-tags=intest,deadlock and (if you add rule/plan-output cases) go test
./pkg/planner -run TestPlannerRules -tags=intest,deadlock; if any planner rule
or logical/physical plan output changed, update the corresponding rule testdata
files under planner testdata and re-run the above commands until they pass.
♻️ Duplicate comments (1)
pkg/planner/core/expression_rewriter.go (1)

2587-2598: ⚠️ Potential issue | 🔴 Critical

Potential DML mis-remap still needs an explicit safety guard.

Line 2587 and Line 2629 apply redundant-column remapping for all WHERE/HAVING rewrites. Please verify this path is safe for UPDATE/DELETE plans where join schema/output names may be reset later; otherwise this can remap to a wrong visible column and alter row qualification.

#!/bin/bash
set -euo pipefail

echo "== ResolveRedundantColumn internals =="
fd 'logical_join.go$' pkg/planner/core -x sh -c '
  f="$1"
  echo "-- $f"
  rg -n -C4 "type LogicalJoin|RedundantColsToOutputIdx|RegisterRedundantColumnMapping|ResolveRedundantColumn|UniqueID|ColumnIndex|Schema\\(\\)\\.Columns" "$f"
' sh {}

echo
echo "== UPDATE/DELETE schema reset points =="
fd 'logical_plan_builder.go$' pkg/planner/core -x sh -c '
  f="$1"
  echo "-- $f"
  rg -n -C4 "inUpdateStmt|inDeleteStmt|SetSchemaAndNames|MergeSchema|RegisterRedundantColumnMapping" "$f"
' sh {}

echo
echo "== Remap call sites =="
rg -n -C3 "resolveRedundantColumnFromNaturalUsingJoinPlan\\(|ResolveRedundantColumn\\(" pkg/planner/core

Expected verification result: if mapping is still stored/used by output index across schema resets, this path remains unsafe for DML and should be switched to UniqueID-based remap or DML-gated.

Also applies to: 2629-2637

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/planner/core/expression_rewriter.go` around lines 2587 - 2598, The
redundant-column remapping in expression_rewriter.go (triggered when er.clause()
is whereClause/havingClause and name.Redundant && name.OrigTblName != "")
currently calls resolveRedundantColumnFromNaturalUsingJoinPlan(planCtx.plan,
column) and assigns mappedCol/mappedName which can be unsafe for UPDATE/DELETE
flows because schema/output names may be reset later; verify and change the fix
by either (A) gating this remap when the plan is in DML (use the plan builder
flags/inUpdateStmt or inDeleteStmt context) so you do not remap for DML plans,
or (B) change the remap to use a UniqueID-based mapping (the same identity used
by
ResolveRedundantColumn/RegisterRedundantColumnMapping/RedundantColsToOutputIdx)
instead of relying on output column names, ensuring the mapping survives
Schema/SetSchemaAndNames/MergeSchema resets; locate the call site in
expression_rewriter.go (the block using
resolveRedundantColumnFromNaturalUsingJoinPlan) and implement one of these two
guards/changes and update any related callers of ResolveRedundantColumn to keep
consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@pkg/planner/core/expression_rewriter.go`:
- Around line 2573-2704: Add targeted planner unit tests that cover
name-resolution and remapping around JOIN ... USING/NATURAL by exercising the
modified functions toColumn, findFieldNameFromNaturalUsingJoin, and
resolveRedundantColumnFromNaturalUsingJoinPlan; run the tests with the exact
commands: go test ./pkg/planner -run TestExpressionRewriter
-tags=intest,deadlock and (if you add rule/plan-output cases) go test
./pkg/planner -run TestPlannerRules -tags=intest,deadlock; if any planner rule
or logical/physical plan output changed, update the corresponding rule testdata
files under planner testdata and re-run the above commands until they pass.

---

Duplicate comments:
In `@pkg/planner/core/expression_rewriter.go`:
- Around line 2587-2598: The redundant-column remapping in
expression_rewriter.go (triggered when er.clause() is whereClause/havingClause
and name.Redundant && name.OrigTblName != "") currently calls
resolveRedundantColumnFromNaturalUsingJoinPlan(planCtx.plan, column) and assigns
mappedCol/mappedName which can be unsafe for UPDATE/DELETE flows because
schema/output names may be reset later; verify and change the fix by either (A)
gating this remap when the plan is in DML (use the plan builder
flags/inUpdateStmt or inDeleteStmt context) so you do not remap for DML plans,
or (B) change the remap to use a UniqueID-based mapping (the same identity used
by
ResolveRedundantColumn/RegisterRedundantColumnMapping/RedundantColsToOutputIdx)
instead of relying on output column names, ensuring the mapping survives
Schema/SetSchemaAndNames/MergeSchema resets; locate the call site in
expression_rewriter.go (the block using
resolveRedundantColumnFromNaturalUsingJoinPlan) and implement one of these two
guards/changes and update any related callers of ResolveRedundantColumn to keep
consistency.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a3aa19 and f274685.

📒 Files selected for processing (3)
  • pkg/planner/core/casetest/schema/cannot_find_column_test.go
  • pkg/planner/core/expression_rewriter.go
  • pkg/planner/core/logical_plan_builder.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/planner/core/casetest/schema/cannot_find_column_test.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/planner/core/casetest/schema/cannot_find_column_test.go (1)

66-74: Add one inline assertion for the exact = ALL (subquery) failing shape.

These explicit checks are useful, but they currently cover nested/having/order-by only. Adding one direct inline query for the original JOIN ... USING + qualified predicate + = ALL (subquery) case would make this file self-protecting even if testdata is later edited.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/planner/core/casetest/schema/cannot_find_column_test.go` around lines 66
- 74, Add a single inline assertion that reproduces the original failing shape:
use tk.MustQuery with a query that uses JOIN ... USING(id) plus a qualified
predicate and an "= ALL (subquery)" construct (for example selecting t1.id from
t1 JOIN t3 USING(id) WHERE t1.left_v = 93 AND t1.id = ALL (SELECT id FROM t3
WHERE t3.id BETWEEN 10 AND 20)) and assert the expected result with
Check(testkit.Rows("10")); place this new tk.MustQuery(...) alongside the
existing related assertions (the lines that call tk.MustQuery currently labeled
/* issue:66272-nested */, /* issue:66272-having */, /* issue:66272-orderby */)
so the file self-validates the original case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/planner/core/casetest/schema/cannot_find_column_test.go`:
- Around line 66-74: Add a single inline assertion that reproduces the original
failing shape: use tk.MustQuery with a query that uses JOIN ... USING(id) plus a
qualified predicate and an "= ALL (subquery)" construct (for example selecting
t1.id from t1 JOIN t3 USING(id) WHERE t1.left_v = 93 AND t1.id = ALL (SELECT id
FROM t3 WHERE t3.id BETWEEN 10 AND 20)) and assert the expected result with
Check(testkit.Rows("10")); place this new tk.MustQuery(...) alongside the
existing related assertions (the lines that call tk.MustQuery currently labeled
/* issue:66272-nested */, /* issue:66272-having */, /* issue:66272-orderby */)
so the file self-validates the original case.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f274685 and cd1ec81.

📒 Files selected for processing (1)
  • pkg/planner/core/casetest/schema/cannot_find_column_test.go

@hawkingrei

Copy link
Copy Markdown
Contributor Author

/retest

@hawkingrei

Copy link
Copy Markdown
Contributor Author

@pantheon-bot review

@pantheon-ai

pantheon-ai Bot commented Feb 28, 2026

Copy link
Copy Markdown

Review Complete

Findings: 2 issues
Posted: 2
Duplicates/Skipped: 0

Comment thread pkg/planner/core/logical_plan_builder.go Outdated
Comment thread pkg/planner/core/expression_rewriter.go
@hawkingrei

Copy link
Copy Markdown
Contributor Author

@pantheon-bot review

@pantheon-ai

pantheon-ai Bot commented Mar 9, 2026

Copy link
Copy Markdown

Review Complete

Findings: 0 issues
Posted: 0
Duplicates/Skipped: 0

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 9, 2026
@ti-chi-bot

ti-chi-bot Bot commented Mar 10, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: guo-shaoge, qw4990

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 10, 2026
@ti-chi-bot

ti-chi-bot Bot commented Mar 10, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-03-09 10:20:00.723987063 +0000 UTC m=+259032.236044734: ☑️ agreed by qw4990.
  • 2026-03-10 03:26:02.022355128 +0000 UTC m=+320593.534412849: ☑️ agreed by guo-shaoge.

@hawkingrei

Copy link
Copy Markdown
Contributor Author

/retest

@ti-chi-bot
ti-chi-bot Bot merged commit 48fa8aa into pingcap:master Mar 10, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Correction Bugfix by AI AI-Testing approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

planner/executor: internal missing-column error with JOIN ... USING + qualified column predicate

3 participants