planner: ignore hidden columns in natural/using join matching (#66069) - #67023
Conversation
|
Hi @qw4990. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughExcludes hidden/internal columns from NATURAL/USING join common-column detection and matching in the logical plan builder, so hidden index-derived columns no longer participate in join-name resolution. Adds integration test that reproduces the NATURAL JOIN with expression indexes scenario. Changes
Sequence Diagram(s)(omitted — change is a focused planner bugfix without a new multi-component sequential flow) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip You can get early access to new features in CodeRabbit.Enable the |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/integrationtest/t/planner/core/issuetest/planner_issue.test (1)
631-640: Add aUSINGjoin assertion for the same hidden-column repro.Line 639 covers
NATURAL JOINwell, but this fix targets NATURAL/USING behavior. Add oneJOIN ... USING (a)query here to protect both paths.➕ Suggested test extension
# Issue65929 drop table if exists t1, t2; create table t1(a int); create table t2(a int); create index idx on t1((a+1)); create index idx on t2((a+2)); insert into t1 values (1); insert into t2 values (1); select * from t1 natural join t2 order by t1.a; +select * from t1 join t2 using(a) order by a; drop table t1, t2;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/integrationtest/t/planner/core/issuetest/planner_issue.test` around lines 631 - 640, Add a second query exercising the USING join path next to the existing NATURAL JOIN line that contains "select * from t1 natural join t2 order by t1.a;": insert a statement that performs the same join using the USING clause (e.g., "select * from t1 join t2 using (a) order by t1.a;") before the "drop table t1, t2;" so both NATURAL JOIN and JOIN ... USING (a) are covered in the test.tests/integrationtest/r/planner/core/issuetest/planner_issue.result (1)
990-1000: Add a companionUSING(a)case to match fix scope.Line 997 covers
NATURAL JOIN, but the fix scope includesUSINGjoins too. A mirroredJOIN ... USING(a)regression would better protect against path-specific regressions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/integrationtest/r/planner/core/issuetest/planner_issue.result` around lines 990 - 1000, Add a mirrored test case that exercises a JOIN ... USING(a) path to match the NATURAL JOIN case: duplicate the existing setup (create tables t1/t2, create indexes idx on t1((a+1)) and on t2((a+2)), insert values) and replace "select * from t1 natural join t2 order by t1.a;" with an equivalent "select * from t1 join t2 using(a) order by t1.a;" (or add it alongside) so the test covers the USING(a) regression path as well.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/integrationtest/r/planner/core/issuetest/planner_issue.result`:
- Around line 990-1000: Add a mirrored test case that exercises a JOIN ...
USING(a) path to match the NATURAL JOIN case: duplicate the existing setup
(create tables t1/t2, create indexes idx on t1((a+1)) and on t2((a+2)), insert
values) and replace "select * from t1 natural join t2 order by t1.a;" with an
equivalent "select * from t1 join t2 using(a) order by t1.a;" (or add it
alongside) so the test covers the USING(a) regression path as well.
In `@tests/integrationtest/t/planner/core/issuetest/planner_issue.test`:
- Around line 631-640: Add a second query exercising the USING join path next to
the existing NATURAL JOIN line that contains "select * from t1 natural join t2
order by t1.a;": insert a statement that performs the same join using the USING
clause (e.g., "select * from t1 join t2 using (a) order by t1.a;") before the
"drop table t1, t2;" so both NATURAL JOIN and JOIN ... USING (a) are covered in
the test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 668ed945-54a4-4763-ad47-7f64d29a23fb
📒 Files selected for processing (3)
pkg/planner/core/logical_plan_builder.gotests/integrationtest/r/planner/core/issuetest/planner_issue.resulttests/integrationtest/t/planner/core/issuetest/planner_issue.test
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AilinKid, hawkingrei The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release-8.5 #67023 +/- ##
================================================
Coverage ? 55.1736%
================================================
Files ? 1821
Lines ? 653928
Branches ? 0
================================================
Hits ? 360796
Misses ? 266442
Partials ? 26690
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
/retest |
|
@EmmaDuDu: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/retest |
|
@EmmaDuDu: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/retest |
1 similar comment
|
/retest |
|
@EmmaDuDu: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@EmmaDuDu: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/retest |
|
@EmmaDuDu: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
/retest |
This is an automated cherry-pick of #66069
What problem does this PR solve?
Issue Number: close #65929
Problem Summary:
NATURAL/USINGjoin could incorrectly treat hidden columns (e.g. expression index backing columns) as common columns, producing wrong join conditions and empty results.What changed and how does it work?
Skip hidden columns when matching common column names for
NATURAL/USINGjoins, so only visible columns participate in the join condition.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
Summary by CodeRabbit
Bug Fixes
Tests