-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
Window frame support #764
Window frame support #764
Conversation
@@ -21,3 +21,17 @@ when the opportunities arise. | |||
If we end up using more of cockroach DB's optimizer, they codegen their | |||
expressions, normalization rules, exploration rules, and execution code | |||
stem from this general setup. | |||
|
|||
## Generators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zachmu summary of codegen
@@ -166,6 +166,19 @@ type WindowFramer interface { | |||
//SlidingInterval(ctx Context) (WindowInterval, WindowInterval, WindowInterval) | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zachmu this is important, will add doc comments
@@ -255,3 +257,162 @@ func (f *GroupByFramer) Interval() (sql.WindowInterval, error) { | |||
func (f *GroupByFramer) SlidingInterval(ctx sql.Context) (sql.WindowInterval, sql.WindowInterval, sql.WindowInterval) { | |||
panic("implement me") | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zachmu this is the point of failure for ROWS frame correctness
) | ||
|
||
//go:generate optgen -out window_frame_factory.og.go -pkg parse frameFactory window_frame_factory.go | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zachmu this is the bottleneck for AST -> plan node correctness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a sound approach, just one major suggestion.
This needs more tests, probably generated as well.
unboundedPreceding bool | ||
startCurrentRow bool | ||
endCurrentRow bool | ||
startPrecedingExpr int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Odd to call these expr when they are ints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if i called them both startNPreceding
?
This PR adds sql.WindowFrame and sql.WindowFramers to represent window frames from AST -> plan -> exec. Every unique and valid combination of window frame Start and End bounds has a plan node (sql.WindowFrame) and a framer (sql.WindowFramer) pair. The frames, framers, and constructor functions that map from AST -> plan and plan -> exec are generated by optgen. Only rowFrameBase implemented in this PR, range frame tests are commented out until rangeFrameBase is implemented.
2274082
to
24a5593
Compare
This PR adds sql.WindowFrame and sql.WindowFramers to represent
window frames from AST -> plan -> exec.
Every unique and valid combination of window frame
Start and End bounds has a plan node (sql.WindowFrame)
and a framer (sql.WindowFramer) pair. The frames, framers,
and constructor functions that map from AST -> plan and
plan -> exec are generated by optgen.