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

opt: remember subquery ASTs for explain #29597

Merged
merged 2 commits into from
Sep 6, 2018

Conversation

RaduBerinde
Copy link
Member

sql: rename "sql" to "original sql" in subquery EXPLAIN

With the optimizer, this field will show the original subquery which
might have been modified by transforms.

Release note: None

opt: remember subquery ASTs for explain

Store the original *tree.Subquery in Any, Exists, Subquery and
use it to populate the subquery during execbuild. This causes the
original subquery to show up in EXPLAIN.

Fixes #29350.

Release note: None

With the optimizer, this field will show the original subquery which
might have been modified by transforms.

Release note: None
@RaduBerinde RaduBerinde requested review from justinj, rytaft, andy-kimball and a team September 5, 2018 17:40
@RaduBerinde RaduBerinde requested a review from a team as a code owner September 5, 2018 17:40
@RaduBerinde RaduBerinde requested review from a team September 5, 2018 17:40
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 5 of 5 files at r1, 14 of 14 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)


pkg/sql/opt/memo/expr_view_format.go, line 395 at r2 (raw file):

	case opt.SubqueryOp, opt.ExistsOp:
		private = nil

We have comments above to explain why private is set to nil for some operators -- might be worth doing that here too.


pkg/sql/opt/norm/rules/decorrelate.opt, line 689 at r2 (raw file):

                (Filters [ (ConstructAnyCondition $input $scalar $subqueryDef) ])
            )
            $subqueryDef

Is there any issue with reusing the same subqueryDef even though this is a different subquery?

Store the original `*tree.Subquery` in `Any`, `Exists`, `Subquery` and
use it to populate the subquery during execbuild. This causes the
original subquery to show up in `EXPLAIN`.

Fixes cockroachdb#29350.

Release note: None
Copy link
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)


pkg/sql/opt/memo/expr_view_format.go, line 395 at r2 (raw file):

Previously, rytaft wrote…

We have comments above to explain why private is set to nil for some operators -- might be worth doing that here too.

Done.


pkg/sql/opt/norm/rules/decorrelate.opt, line 689 at r2 (raw file):

Previously, rytaft wrote…

Is there any issue with reusing the same subqueryDef even though this is a different subquery?

No, that's the point of OriginalExpr. It's true that we copy Cmp too but it's fine since it's not used by Exists.

Copy link
Contributor

@andy-kimball andy-kimball left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 5 of 5 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 2 stale)

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale)

@RaduBerinde
Copy link
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Sep 6, 2018
29597: opt: remember subquery ASTs for explain r=RaduBerinde a=RaduBerinde

#### sql: rename "sql" to "original sql" in subquery EXPLAIN

With the optimizer, this field will show the original subquery which
might have been modified by transforms.

Release note: None

#### opt: remember subquery ASTs for explain

Store the original `*tree.Subquery` in `Any`, `Exists`, `Subquery` and
use it to populate the subquery during execbuild. This causes the
original subquery to show up in `EXPLAIN`.

Fixes #29350.

Release note: None


Co-authored-by: Radu Berinde <[email protected]>
@craig
Copy link
Contributor

craig bot commented Sep 6, 2018

Build succeeded

@craig craig bot merged commit 3eab8d4 into cockroachdb:master Sep 6, 2018
@RaduBerinde RaduBerinde deleted the subquery-info branch September 6, 2018 23:37
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.

4 participants