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

sql: prohibit offset with GROUPS containing vars #38270

Merged
merged 1 commit into from
Jun 18, 2019

Conversation

justinj
Copy link
Contributor

@justinj justinj commented Jun 18, 2019

This commit adds a check during semantic analysis to verify that a
window function using GROUPS mode does not include an offset expression
containing variable references. This was handled by the heuristic planner
previously, but this places a check earlier so that it's also checked by the
optimizer.

Fixes #38090

Release note: None

@justinj justinj requested a review from yuzefovich June 18, 2019 17:21
@justinj justinj requested a review from a team as a code owner June 18, 2019 17:21
@justinj justinj requested a review from a team June 18, 2019 17:21
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

Nice! :lgtm:

Reviewed 3 of 3 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @justinj)


pkg/sql/opt/optbuilder/testdata/window, line 1553 at r1 (raw file):


build
SELECT rank() OVER (ORDER BY k GROUPS k PRECEDING) FROM kv

I'm just wondering whether the optimizer already does the check that GROUPS mode requires ORDER BY clause (I have an old PR to fix that in HP and probably in CBO as well)?

This commit adds a check during semantic analysis to verify that a
window function using GROUPS mode does not include an offset expression
containing variable references.

Release note: None
@justinj
Copy link
Contributor Author

justinj commented Jun 18, 2019

TFTR!

Seems we definitely don't handle that in the optimizer. Any chance you could revive your old PR? I took a look into fixing that alongside this change but it seemed like there was some stuff that needed to happen with named windows that made it non-trivial. If reviving yours isn't easy then let's open an issue for it.

bors r+

craig bot pushed a commit that referenced this pull request Jun 18, 2019
38270: sql: prohibit offset with GROUPS containing vars r=justinj a=justinj

This commit adds a check during semantic analysis to verify that a
window function using GROUPS mode does not include an offset expression
containing variable references. This was handled by the heuristic planner
previously, but this places a check earlier so that it's also checked by the
optimizer.

Fixes #38090

Release note: None

Co-authored-by: Justin Jaffray <justin@cockroachlabs.com>
@yuzefovich
Copy link
Member

I will revive that PR together with Jordan today since he's in SF. Hopefully we'll get it done :)

@craig
Copy link
Contributor

craig bot commented Jun 18, 2019

Build succeeded

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.

sql: internal error: indexed var must be bound to a container before evaluation
3 participants