Repository navigation
planner: fix IN-subquery join+agg rewrite duplication with implicit casted RHS keys - #66897
Conversation
|
Review failed due to infrastructure/execution failure after retries. Please re-trigger review. ℹ️ Learn more details on Pantheon AI. |
|
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 (3)
📝 WalkthroughWalkthroughThis PR fixes a row duplication bug in IN-subquery processing by enhancing the query planner's IN-subquery-to-join rewrite logic. It adds support for projecting the RHS key when implicit casting occurs, enabling proper coercion handling. The fix includes comprehensive test cases covering BLOB columns and various join scenarios. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 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)
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 |
|
@pantheon-ai please review |
|
⏳ @qw4990 I've received your follow-up and will continue on this pull request. I'll update this comment when I have something to share. ℹ️ Learn more details on Pantheon AI. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #66897 +/- ##
================================================
- Coverage 77.6785% 77.4514% -0.2271%
================================================
Files 2012 1933 -79
Lines 550824 538292 -12532
================================================
- Hits 427872 416915 -10957
- Misses 121244 121375 +131
+ Partials 1708 2 -1706
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
[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:
|
What problem does this PR solve?
Issue Number: close #64230
Problem Summary: planner: fix IN-subquery join+agg rewrite duplication with implicit casted RHS keys
What changed and how does it work?
Fix a semantic mismatch in
IN (subquery)rewrite (tidb_opt_insubq_to_join_and_agg=1) that could duplicate outer rows when the inner comparison key is implicitly cast.Before this change, TiDB could rewrite:
outer_col IN (SELECT inner_col ...)into
INNER JOIN + DISTINCT(inner_col)and deduplicate on raw inner values. In some cases (for exampleBLOB/string values compared to numeric), different raw inner values become equal after implicit cast during=comparison, so the rewritten join could match multiple inner rows and return duplicated outer rows.This patch makes deduplication happen on the same RHS comparison key domain used by the join predicate:
DISTINCTon that projected keyCheck 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