-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Support interval '1 month' + date/timestamp: Handle binary op interval in logical AST builder
#6270
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
Conversation
|
@jackwener I have more test cases coming up |
interval '1 month' + date/timestamp: Handle binary op interval in logical AST builder
alamb
left a comment
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.
Looks great to me -- thank you @aprimadi
It is quite a series of PRs you have contributed recently 🏅
datafusion/core/tests/sqllogictests/test_files/type_coercion.slt
Outdated
Show resolved
Hide resolved
alamb
left a comment
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.
Looks great to me -- thank you @aprimadi
It is quite a series of PRs you have contributed recently 🏅
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
alamb
left a comment
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.
Thanks again @aprimadi
alamb
left a comment
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.
Thanks again @aprimadi
Which issue does this PR close?
Closes #6205.
Rationale for this change
Due to sqlparser lack of semantic, we need to rewrite the AST in datafusion.
For example, this is valid in sqlparser:
This is also valid:
Both generates structurally similar interval expression with BinaryOp +.
The first statement generates the following AST (SELECT omitted):
The second statement generates the following AST (SELECT omitted):
I don't think this can be handled in sqlparser because sqlparser doesn't have the semantic to understand which BinaryOp + cast is and isn't allowed.
This PR transforms the 2nd AST (or any AST with non string literal value in right operand) into:
What changes are included in this PR?
Are these changes tested?
Yes
Are there any user-facing changes?
No