-
Notifications
You must be signed in to change notification settings - Fork 21
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 function frames, extent, and bounds #104
Conversation
a4c4d3f
to
1c3abe2
Compare
Adds parsing capabilities for window frames, including one sided frames, two sided frames, RANGE value frames, integral and interval based frames, and errors for semantically incorect combinations of frame options. Only value based intervals are currently supported. Prepared bound expressions are not supported.
a6b1b51
to
dcfa863
Compare
go/vt/sqlparser/ast.go
Outdated
} | ||
|
||
// Format formats the node. | ||
func (node *FrameBound) print(buf *TrackedBuffer) { |
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.
should FrameBound
implement Node
? the Format function would be empty, but it's useful in the AST
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.
Why would the format function be empty? It has a textual representation, right?
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.
was confused, realize now that node printing is recursive
5cc057d
to
4cf6dff
Compare
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.
You were tricked by a trap in the parse testing framework, see comments
} | ||
|
||
// Format formats the node. | ||
func (node *Frame) Format(buf *TrackedBuffer) { |
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.
Not printing Extent
here is a red flag
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.
I don't actually know how these tests pass
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.
The reason they pass is because you have been fooled: in these tests, select expressions echo their textual input unless you tell the test case serializeSelectExprs: true
When you add that to one of these cases, you can see they don't actually work, no range info is printed:
expected: "select name, dense_rank() over (partition by x order by y RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) from t"
actual : "select name, dense_rank() over (partition by x order by y asc) from t"
From a brief look, it seems most of the OVER tests have this issue
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.
the opposite is now default, need to specify useSelectExpressionLiteral
to sidestep parsing
go/vt/sqlparser/ast.go
Outdated
} | ||
|
||
// Format formats the node. | ||
func (node *FrameBound) print(buf *TrackedBuffer) { |
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.
Why would the format function be empty? It has a textual representation, right?
Signed-off-by: Max Hoffman <max@dolthub.com>
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.
LGTM!
Adds parsing capabilities for window frames, including one sided frames, two sided frames, RANGE value frames, integral and interval based frames, and errors for semantically incorect combinations of frame options. Only value based intervals are currently supported. No prepared statement support for expression bounds.