Skip to content

Set parsed comments in operator for subqueries (#18369) #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 7, 2025

Conversation

mhamza15
Copy link

@mhamza15 mhamza15 commented Aug 7, 2025

This is a backport of vitessio#18369

Description

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported
  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

@mhamza15 mhamza15 self-assigned this Aug 7, 2025
@Copilot Copilot AI review requested due to automatic review settings August 7, 2025 16:29
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements proper comment preservation when merging subqueries with outer queries in Vitess's query planner. The change ensures that SQL comments from the original query are retained in the merged operator when subqueries are consolidated into a single route.

Key changes:

  • Added logic to preserve comments when merging subqueries with outer queries
  • Added test cases to verify comment preservation in both merged and non-merged subquery scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
go/vt/vtgate/planbuilder/operators/subquery_planning.go Added comment preservation logic in the subquery merge function
go/vt/vtgate/planbuilder/testdata/select_cases.json Added test cases for comment handling with subqueries

"user.user"
]
},
"skip_e2e": true
Copy link
Member

Choose a reason for hiding this comment

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

This skip_e2e attribute does not exist on v21 yet, so you might have to remove this here and in the other test case. This is causing the unit test failure:

        --- FAIL: TestPlanTestSuite/TestPlan/select_cases.json (0.00s)
panic: json: unknown field "skip_e2e" [recovered]
	panic: json: unknown field "skip_e2e"

goroutine 1042 [running]:
testing.tRunner.func1.2({0x16b53c0, 0xc00074a6f0})
	/opt/hostedtoolcache/go/1.22.12/x64/src/testing/testing.go:1631 +0x24a
testing.tRunner.func1()
	/opt/hostedtoolcache/go/1.22.12/x64/src/testing/testing.go:1634 +0x377
panic({0x16b53c0?, 0xc00074a6f0?})
	/opt/hostedtoolcache/go/1.22.12/x64/src/runtime/panic.go:770 +0x132
vitess.io/vitess/go/vt/vtgate/planbuilder.readJSONTests({0x18f7525, 0x11})
	/home/runner/work/vitess-gh/vitess-gh/go/vt/vtgate/planbuilder/plan_test.go:724 +0xf0
vitess.io/vitess/go/vt/vtgate/planbuilder.(*planTestSuite).testFile.func1(0xc0007731e0)
	/home/runner/work/vitess-gh/vitess-gh/go/vt/vtgate/planbuilder/plan_test.go:658 +0x8d
testing.tRunner(0xc0007731e0, 0xc000760200)
	/opt/hostedtoolcache/go/1.22.12/x64/src/testing/testing.go:1689 +0xfb
created by testing.(*T).Run in goroutine 250
	/opt/hostedtoolcache/go/1.22.12/x64/src/testing/testing.go:1742 +0x390
FAIL	vitess.io/vitess/go/vt/vtgate/planbuilder	1.095s

@arthurschreiber arthurschreiber merged commit aa56cad into release-20.0-github Aug 7, 2025
178 of 182 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants