Skip to content

planner, executor: standardize how EXPLAIN output is formatted in testkit.Rows - #67270

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
henrybw:fix-explain-row-format-tests
Mar 25, 2026
Merged

ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
henrybw:fix-explain-row-format-tests

Conversation

@henrybw

@henrybw henrybw commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #67269

Problem Summary:

Most existing tests that check EXPLAIN plan output use separate arguments for each line. For example:

tk.MustQuery(`explain format='plan_tree' select * from t1 join t2 on t1.a=t2.b where t1.a in (1,2);`).Check(testkit.Rows(
	`HashJoin root  inner join, equal:[eq(test.t1.a, test.t2.b)]`,
	`├─Batch_Point_Get(Build) root table:t1 handle:[1 2], keep order:false, desc:false`,
	`└─TableReader(Probe) root  MppVersion: 3, data:ExchangeSender`,
	`  └─ExchangeSender mpp[tiflash]  ExchangeType: PassThrough`,
	`    └─TableFullScan mpp[tiflash] table:t2 pushed down filter:in(test.t2.b, 1, 2), not(isnull(test.t2.b)), keep order:false, stats:pseudo`))

However, a couple of tests instead tests used a single concatenated string with literal ]\n[ separators, instead of separate arguments to testkit.Rows(), like this:

testKit.MustQuery("explain format = 'brief' select /*+AGG_TO_COP()*/ count(*) from t32157 ignore index(primary) where process_code = 'GDEP0071'").Check(testkit.Rows(
	"StreamAgg 1.00 root  funcs:count(1)->Column#9]\n" +
		"[└─UnionScan 10.00 root  eq(test.t32157.process_code, \"GDEP0071\")]\n" +
		"[  └─TableReader 10.00 root  data:Selection]\n" +
		"[    └─Selection 10.00 cop[tikv]  eq(test.t32157.process_code, \"GDEP0071\")]\n" +
		"[      └─TableFullScan 10000.00 cop[tikv] table:t32157 keep order:false, stats:pseudo"))

While this worked because testkit.Rows splits on \n and strips brackets, it is unnecessarily inconsistent with every other test case that checks EXPLAIN output.

What changed and how does it work?

Instead, convert these two tests to use separate arguments, like all of the other tests that check EXPLAIN output:

  • pkg/planner/core/integration_test.go (TestAggPushToCopForCachedTable)
  • pkg/executor/test/showtest/show_test.go (TestShow2)

No functional changes.

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
    • Refactored test assertion formatting for improved code maintainability and clarity.

…testkit.Rows`

Most existing tests that check `EXPLAIN` plan output use separate arguments
for each line. For example:

```
tk.MustQuery(`explain format='plan_tree' select * from t1 join t2 on t1.a=t2.b where t1.a in (1,2);`).Check(testkit.Rows(
	`HashJoin root  inner join, equal:[eq(test.t1.a, test.t2.b)]`,
	`├─Batch_Point_Get(Build) root table:t1 handle:[1 2], keep order:false, desc:false`,
	`└─TableReader(Probe) root  MppVersion: 3, data:ExchangeSender`,
	`  └─ExchangeSender mpp[tiflash]  ExchangeType: PassThrough`,
	`    └─TableFullScan mpp[tiflash] table:t2 pushed down filter:in(test.t2.b, 1, 2), not(isnull(test.t2.b)), keep order:false, stats:pseudo`))
```

However, a couple of tests instead tests used a single concatenated string
with literal `]\n[` separators, instead of separate arguments to
`testkit.Rows()`. This worked because `testkit.Rows` splits on `\n` and
strips brackets.

Instead, convert these two tests to use separate arguments, like all of the
other tests that check `EXPLAIN` output.
@ti-chi-bot ti-chi-bot Bot added the release-note-none Denotes a PR that doesn't merit a release note. label Mar 25, 2026
@pantheon-ai

pantheon-ai Bot commented Mar 25, 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. sig/planner SIG: Planner labels Mar 25, 2026
@tiprow

tiprow Bot commented Mar 25, 2026

Copy link
Copy Markdown

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

coderabbitai Bot commented Mar 25, 2026 •

Copy link
Copy Markdown

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: 155ef280-e852-4d76-ae23-a776cd208efb

📥 Commits

Reviewing files that changed from the base of the PR and between 697da12 and f443e79.

📒 Files selected for processing (2)
  • pkg/executor/test/showtest/show_test.go
  • pkg/planner/core/integration_test.go

📝 Walkthrough

Walkthrough

Two test files are updated to refactor testkit.Rows() calls that incorrectly passed all rows as a single concatenated string with newline separators. The calls are restructured to pass each row as a separate argument, aligning with the codebase convention.

Changes

Cohort / File(s) Summary
Test Formatting Refactoring
pkg/executor/test/showtest/show_test.go, pkg/planner/core/integration_test.go
Refactored testkit.Rows() calls in TestShow2 and TestAggPushToCopForCachedTable from single concatenated strings with embedded newline/bracket separators to multi-argument function calls with each row as a separate string argument.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested labels

sig/planner, approved, lgtm

Suggested reviewers

  • qw4990
  • hawkingrei
  • winoros

Poem

🐰 Hops with glee through test files clean,
Each row now separate, no strings between,
No more brackets hiding in the fold,
Convention shines, a sight to behold! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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 clearly and concisely identifies the main change: standardizing EXPLAIN output formatting in testkit.Rows across two test files.
Description check ✅ Passed The description provides clear context, problem summary, detailed explanation of changes, proper issue reference, and appropriate checklist selections.
Linked Issues check ✅ Passed The PR directly addresses issue #67269 by converting the two identified tests to use separate arguments in testkit.Rows, matching the standard convention used across the codebase.
Out of Scope Changes check ✅ Passed All changes are narrowly focused on reformatting EXPLAIN output in two test files to standardize formatting, with no functional changes or unrelated modifications.

✏️ 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.3)

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.

@hawkingrei

Copy link
Copy Markdown
Contributor

/ok-to-test

@ti-chi-bot ti-chi-bot Bot added the ok-to-test Indicates a PR is ready to be tested. label Mar 25, 2026
@codecov

codecov Bot commented Mar 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.0235%. Comparing base (697da12) to head (f443e79).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #67270        +/-   ##
================================================
+ Coverage   77.8044%   78.0235%   +0.2191%     
================================================
  Files          2022       1942        -80     
  Lines        554886     548119      -6767     
================================================
- Hits         431726     427662      -4064     
+ Misses       121416     120440       -976     
+ Partials       1744         17      -1727     
Flag Coverage Δ
integration 41.5336% <ø> (-6.5828%) ⬇️
unit 77.1970% <ø> (+0.8675%) ⬆️

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

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

@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.

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

@0xPoe 0xPoe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! :shipit:

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

ti-chi-bot Bot commented Mar 25, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-03-25 05:53:03.469849779 +0000 UTC m=+333979.505920039: ☑️ agreed by terry1purcell.
  • 2026-03-25 08:53:48.828533632 +0000 UTC m=+344824.864603882: ☑️ agreed by 0xPoe.

@ti-chi-bot

ti-chi-bot Bot commented Mar 25, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 0xPoe, qw4990, terry1purcell

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

@0xPoe

0xPoe commented Mar 25, 2026

Copy link
Copy Markdown
Member

/retest

@henrybw

henrybw commented Mar 25, 2026

Copy link
Copy Markdown
Contributor Author

/retest-required

1 similar comment
@henrybw

henrybw commented Mar 25, 2026

Copy link
Copy Markdown
Contributor Author

/retest-required

@ti-chi-bot
ti-chi-bot Bot merged commit 598c3b4 into pingcap:master Mar 25, 2026
35 checks passed
@henrybw
henrybw deleted the fix-explain-row-format-tests branch March 26, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

planner: malformed testkit.Rows calls pass all rows as a single concatenated string

5 participants