Skip to content
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

Unnest simple subqueries #6831

Merged
merged 2 commits into from
Oct 11, 2020
Merged

Conversation

systay
Copy link
Collaborator

@systay systay commented Oct 7, 2020

This PR adds logic to simplify subquery expressions that are simple to unnest.

If a query contains an expression looking something like:

SELECT * FROM user WHERE col = (SELECT 42)

this PR will unnest that subquery so that the query that is planned is instead:

SELECT * FROM user WHERE col = 42

Fixes #6827

Comment on lines 381 to 383
exec(t, conn, "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = (SELECT SCHEMA()) AND TABLE_NAME = 'product' AND COLUMN_KEY = 'PRI'")
}
Copy link
Member

Choose a reason for hiding this comment

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

nice to add assert for the query result.

Copy link
Member

@GuptaManan100 GuptaManan100 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@harshit-gangal harshit-gangal left a comment

Choose a reason for hiding this comment

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

As I approved this earlier, making this as blocking so that I understand the change before merging.

go/vt/vtgate/executor_select_test.go Outdated Show resolved Hide resolved
Copy link
Member

@harshit-gangal harshit-gangal left a comment

Choose a reason for hiding this comment

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

I looked as old commit. Ignore my previous comment.
One comment on test expectations.

go/vt/vtgate/executor_select_test.go Outdated Show resolved Hide resolved
@systay systay changed the title Rewrite more queries Unnest simple subqueries Oct 8, 2020
@systay systay added the Type: Enhancement Logical improvement (somewhere between a bug and feature) label Oct 8, 2020
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
@systay systay merged commit c8114b4 into vitessio:master Oct 11, 2020
@askdba askdba modified the milestone: v8.0 Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

INFORMATION_SCHEMA.TABLE_SCHEMA comparison with dynamic value no longer works
4 participants