Skip to content

planner: migrate testdata-backed EXPLAIN tests to format='plan_tree'#67502

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
henrybw:migrate-explain-plantree-4
Apr 2, 2026
Merged

planner: migrate testdata-backed EXPLAIN tests to format='plan_tree'#67502
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
henrybw:migrate-explain-plantree-4

Conversation

@henrybw
Copy link
Copy Markdown
Contributor

@henrybw henrybw commented Apr 2, 2026

What problem does this PR solve?

Issue Number: ref #67112

Problem Summary: Test cases that rely on EXPLAIN output in format='brief' or format='verbose', but only need to validate the structure of the plan, are brittle and will start failing if minor changes in row estimates or table schema occur. This requires regenerating a large number of new plans for optimizer tests when making changes, adding noise to PR diffs and obscuring potential problems that these tests may have otherwise caught.

What changed and how does it work?

Convert EXPLAIN tests that use testdata recorded from format='brief' to format='plan_tree', and re-record their output:

  • runtime_filter_generator_test.go + testdata
  • operator/logicalop/logicalop_test/ + testdata
  • casetest/cascades/ + testdata
  • casetest/integration_test.go
  • casetest/partition/partition_pruner_test.go
  • casetest/plancache/plan_cache_partition_test.go

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.

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

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Summary by CodeRabbit

  • Tests

    • Updated query plan validation tests to use an improved explain format for better consistency and clarity across test suites.
  • Chores

    • Refreshed expected test outputs across multiple test data files to align with updated plan formatting standards.

Convert `EXPLAIN` tests that use testdata recording from `format='brief'`
to `format='plan_tree'`, and re-record their output:

- runtime_filter_generator_test.go + testdata
- operator/logicalop/logicalop_test/ + testdata
- casetest/cascades/ + testdata
- casetest/integration_test.go
- casetest/partition/partition_pruner_test.go
- casetest/plancache/plan_cache_partition_test.go
@ti-chi-bot ti-chi-bot Bot added the release-note-none Denotes a PR that doesn't merit a release note. label Apr 2, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai Bot commented Apr 2, 2026

Review Complete

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

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot Bot added sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 2, 2026
@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 2, 2026

Hi @henrybw. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c4fb08fb-4f1a-4a60-88d3-f833a4213ae3

📥 Commits

Reviewing files that changed from the base of the PR and between 8412422 and 573b4c4.

📒 Files selected for processing (11)
  • pkg/planner/core/casetest/cascades/memo_test.go
  • pkg/planner/core/casetest/cascades/testdata/cascades_template_out.json
  • pkg/planner/core/casetest/cascades/testdata/cascades_template_xut.json
  • pkg/planner/core/casetest/integration_test.go
  • pkg/planner/core/casetest/partition/partition_pruner_test.go
  • pkg/planner/core/casetest/plancache/plan_cache_partition_test.go
  • pkg/planner/core/operator/logicalop/logicalop_test/logical_operator_test.go
  • pkg/planner/core/operator/logicalop/logicalop_test/testdata/cascades_suite_out.json
  • pkg/planner/core/operator/logicalop/logicalop_test/testdata/cascades_suite_xut.json
  • pkg/planner/core/runtime_filter_generator_test.go
  • pkg/planner/core/testdata/runtime_filter_generator_suite_out.json

📝 Walkthrough

Walkthrough

This PR updates planner core unit tests to use EXPLAIN format='plan_tree' instead of EXPLAIN format='brief', and correspondingly updates all expected test output data to match the new format. Plan representations are reformatted to remove numeric cost annotations and normalize column identifiers.

Changes

Cohort / File(s) Summary
Test File Format Migration
pkg/planner/core/casetest/cascades/memo_test.go, pkg/planner/core/casetest/integration_test.go, pkg/planner/core/casetest/partition/partition_pruner_test.go, pkg/planner/core/casetest/plancache/plan_cache_partition_test.go, pkg/planner/core/operator/logicalop/logicalop_test/logical_operator_test.go, pkg/planner/core/runtime_filter_generator_test.go
Updated test assertions to generate and validate query plans using EXPLAIN format='plan_tree' instead of format='brief'.
Testdata Plan Output Updates
pkg/planner/core/casetest/cascades/testdata/cascades_template_out.json, pkg/planner/core/casetest/cascades/testdata/cascades_template_xut.json, pkg/planner/core/operator/logicalop/logicalop_test/testdata/cascades_suite_out.json, pkg/planner/core/operator/logicalop/logicalop_test/testdata/cascades_suite_xut.json, pkg/planner/core/testdata/runtime_filter_generator_suite_out.json
Updated expected plan strings by removing numeric cost/cardinality prefixes (e.g., 1.00, 6400.00), normalizing column identifiers from specific numbers to generic Column placeholders, and reformatting node descriptors while preserving operator hierarchy and expressions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

sig/planner, size/XXL, ok-to-test

Suggested reviewers

  • hawkingrei
  • qw4990
  • AilinKid

Poem

🐰 The planner tests now dance in trees,
No cost or column numbers please!
From brief to plan_tree we leap with glee,
Reformatted rows, a sight to see! 🌳✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: migrating testdata-backed EXPLAIN tests from brief format to plan_tree format.
Description check ✅ Passed The pull request description follows the template structure, includes a referenced issue number, explains the problem and solution, and marks appropriate test checkboxes. All required sections are present and adequately filled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

Command failed


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.

❤️ Share

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.5459%. Comparing base (8412422) to head (573b4c4).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #67502        +/-   ##
================================================
- Coverage   77.7173%   77.5459%   -0.1714%     
================================================
  Files          1959       1943        -16     
  Lines        543377     543390        +13     
================================================
- Hits         422298     421377       -921     
- Misses       120238     122011      +1773     
+ Partials        841          2       -839     
Flag Coverage Δ
integration 40.9439% <ø> (+4.7691%) ⬆️
unit 76.7046% <ø> (+0.3615%) ⬆️

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

Components Coverage Δ
dumpling 61.5065% <ø> (ø)
parser ∅ <ø> (∅)
br 48.9074% <ø> (-12.0727%) ⬇️
🚀 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.

Copy link
Copy Markdown

@pantheon-ai pantheon-ai Bot left a comment

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.

@henrybw
Copy link
Copy Markdown
Contributor Author

henrybw commented Apr 2, 2026

/retest-required

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 2, 2026

@henrybw: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest-required

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.

@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 2, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 2, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, 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 Apr 2, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 2, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-02 01:56:01.062408046 +0000 UTC m=+402966.267768103: ☑️ agreed by hawkingrei.
  • 2026-04-02 02:50:15.707833415 +0000 UTC m=+406220.913193462: ☑️ agreed by qw4990.

@hawkingrei
Copy link
Copy Markdown
Member

/retest

2 similar comments
@hawkingrei
Copy link
Copy Markdown
Member

/retest

@hawkingrei
Copy link
Copy Markdown
Member

/retest

@ti-chi-bot ti-chi-bot Bot merged commit 8a45fc4 into pingcap:master Apr 2, 2026
35 checks passed
bitloi pushed a commit to bitloi/tidb that referenced this pull request Apr 2, 2026
@henrybw henrybw deleted the migrate-explain-plantree-4 branch April 2, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. 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.

3 participants