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: fix hidden column handling for WITH #41187

Merged
merged 1 commit into from
Oct 1, 2019

Conversation

RaduBerinde
Copy link
Member

Remove hidden columns from CTE sources. Statements that return hidden
columns are rare but they do exist (EXPLAIN, SHOW ZONE CONFIGURATION).
When used as a CTE, these hidden columns should be removed.

Also making a small fix to removeHiddenCols: it's not ok to remove a
hidden column if it is referenced by the ordering; now we move the
hidden columns to extraCols instead. I could not come up with an
example where this was a problem with the current uses.

Release justification: low-cost fix to new functionality.

Release note: None

Remove hidden columns from CTE sources. Statements that return hidden
columns are rare but they do exist (EXPLAIN, SHOW ZONE CONFIGURATION).
When used as a CTE, these hidden columns should be removed.

Also making a small fix to `removeHiddenCols`: it's not ok to remove a
hidden column if it is referenced by the ordering; now we move the
hidden columns to `extraCols` instead. I could not come up with an
example where this was a problem with the current uses.

Release justification: low-cost fix to new functionality.

Release note: None
@RaduBerinde RaduBerinde requested a review from a team as a code owner September 29, 2019 09:44
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@justinj justinj left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @justinj, @RaduBerinde, and @rytaft)


pkg/sql/opt/optbuilder/testdata/with, line 768 at r1 (raw file):

# Check hidden column handling: level, node_type should not be output.
build
WITH cte AS (EXPLAIN (VERBOSE) SELECT 1) SELECT * FROM cte

this is allowed??

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! 1 of 0 LGTMs obtained (waiting on @justinj and @rytaft)


pkg/sql/opt/optbuilder/testdata/with, line 768 at r1 (raw file):

Previously, justinj (Justin Jaffray) wrote…

this is allowed??

Yeah.. We could trim down the list of supported statements, but I think it's valuable to support at least everything that [ ... ] supports so there aren't cases where you're forced to use the bracket syntax.

@RaduBerinde
Copy link
Member Author

bors r+

1 similar comment
@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Oct 1, 2019

Build failed

@RaduBerinde
Copy link
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Oct 1, 2019
41187: opt: fix hidden column handling for WITH r=RaduBerinde a=RaduBerinde

Remove hidden columns from CTE sources. Statements that return hidden
columns are rare but they do exist (EXPLAIN, SHOW ZONE CONFIGURATION).
When used as a CTE, these hidden columns should be removed.

Also making a small fix to `removeHiddenCols`: it's not ok to remove a
hidden column if it is referenced by the ordering; now we move the
hidden columns to `extraCols` instead. I could not come up with an
example where this was a problem with the current uses.

Release justification: low-cost fix to new functionality.

Release note: None

Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Oct 1, 2019

Build succeeded

@craig craig bot merged commit 120a07e into cockroachdb:master Oct 1, 2019
@knz knz mentioned this pull request Oct 2, 2019
18 tasks
@RaduBerinde RaduBerinde deleted the with-hidden-cols branch October 15, 2019 20:45
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