Skip to content

planner: fix join reorder schema mismatch with full schema columns#66116

Open
hawkingrei wants to merge 9 commits intopingcap:masterfrom
hawkingrei:pr-66106-join-reorder
Open

planner: fix join reorder schema mismatch with full schema columns#66116
hawkingrei wants to merge 9 commits intopingcap:masterfrom
hawkingrei:pr-66106-join-reorder

Conversation

@hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Feb 6, 2026

What problem does this PR solve?

Issue Number: close #66106, close #66107, close #66108

Problem Summary:
Join reorder may build intermediate join trees whose output schema misses columns referenced by remaining join predicates, causing planner failures like Can't find column.
In addition, reports-based regression replay previously depended on local ad-hoc report folders, making coverage non-deterministic.

What changed and how does it work?

  • Add regression coverage in pkg/planner/core/casetest/join/join_test.go (TestCantFindColumnJoinReorder).
  • Add deterministic reports replay test and fixture data:
    • pkg/planner/core/casetest/join/reports_test.go
    • pkg/planner/core/casetest/join/testdata/reports/case_65454/*
    • pkg/planner/core/casetest/join/BUILD.bazel
  • In pkg/planner/core/rule_join_reorder.go:
    • use join FullSchema when checking predicate ownership during reorder
    • preserve/append predicate-related columns for reordered join nodes
    • keep condition/schema consistency when constructing new join nodes
  • In pkg/planner/core/operator/logicalop/logical_join.go:
    • add helper methods to append required columns from FullSchema
    • ensure condition columns can be recovered into join output schema when needed

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.

Manual test scripts:

  • go test -run TestCantFindColumnJoinReorder --tags=intest ./pkg/planner/core/casetest/join -count=1
  • go test -run TestReportsCantFindColumn --tags=intest ./pkg/planner/core/casetest/join -count=1
  • go test -run TestLeadingHintInapplicableKeepsOtherConds --tags=intest ./pkg/planner/core/casetest/rule -count=1

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 a planner error where join reorder could produce "Can't find column" due to schema mismatch in reordered join predicates, and make related reports-based regression replay deterministic.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 6, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-triage-completed sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 6, 2026
@tiprow
Copy link

tiprow bot commented Feb 6, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@hawkingrei hawkingrei marked this pull request as ready for review February 6, 2026 08:30
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 6, 2026
@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 6, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 7, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign terry1purcell for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found 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

@tiprow
Copy link

tiprow bot commented Feb 7, 2026

@hawkingrei: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow 808981f link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 7, 2026

@hawkingrei: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/mysql-test 808981f link true /test mysql-test
pull-unit-test-next-gen 808981f link true /test pull-unit-test-next-gen
idc-jenkins-ci-tidb/check_dev 808981f link true /test check-dev
idc-jenkins-ci-tidb/unit-test 808981f link true /test unit-test
idc-jenkins-ci-tidb/check_dev_2 808981f link true /test check-dev2

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/needs-triage-completed release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

1 participant