-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-27924][SQL] Support ANSI SQL Boolean-Predicate syntax #25074
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
Changes from 28 commits
4a9ac98
3963455
00cc822
5e72437
349d865
4ef1c12
3013cee
6629b33
a0d2d07
05d36f9
bd05be2
97e7812
782b75e
b2fc258
fa148db
c22f12d
fc207e1
3f36c0c
189e805
26c8658
d6abc38
a9cc3ce
2719224
efe5a51
bd71665
67db695
65d4100
ebd2dcf
4794b67
ae126e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1210,6 +1210,7 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging | |
| * - (NOT) LIKE | ||
| * - (NOT) RLIKE | ||
| * - IS (NOT) NULL. | ||
| * - IS (NOT) (TRUE | FALSE | UNKNOWN) | ||
| * - IS (NOT) DISTINCT FROM | ||
| */ | ||
| private def withPredicate(e: Expression, ctx: PredicateContext): Expression = withOrigin(ctx) { | ||
|
|
@@ -1243,6 +1244,18 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging | |
| IsNotNull(e) | ||
| case SqlBaseParser.NULL => | ||
| IsNull(e) | ||
| case SqlBaseParser.TRUE => ctx.NOT match { | ||
| case null => IsTrue(e) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't it simply
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cloud-fan It looks more reasonable.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I missed that approach and the @cloud-fan one sounds more reasonable. If @dongjoon-hyun is not against the idea, can you make a PR for that? @beliefer
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cloud-fan @maropu Let's wait @dongjoon-hyun , then I will make a PR.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for being late. +1 for that approach.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the check, @dongjoon-hyun ! Plz go ahead, @beliefer
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. |
||
| case _ => IsNotTrue(e) | ||
| } | ||
| case SqlBaseParser.FALSE => ctx.NOT match { | ||
| case null => IsFalse(e) | ||
| case _ => IsNotFalse(e) | ||
| } | ||
| case SqlBaseParser.UNKNOWN => ctx.NOT match { | ||
| case null => IsUnknown(e) | ||
| case _ => IsNotUnknown(e) | ||
| } | ||
| case SqlBaseParser.DISTINCT if ctx.NOT != null => | ||
| EqualNullSafe(e, expression(ctx.right)) | ||
| case SqlBaseParser.DISTINCT => | ||
|
|
||
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.
Sorry for adding a comment for the late review rounds, but shall we avoid adding DSL since the whole picture is to support PostgreSQL feature parity? How do you think about that, @maropu ? Can we remove these DSL addition?
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.
In that case, we should revert this and
test("is true | false | unknown expressions").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 have a strong opnion on this though, +1 for your opnion. I don't think all the syntaxes need to be listed up here (It is enough to list up a basic part of them).
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.
@dongjoon-hyun This is not only a PostgreSQL feature, but a ANSI SQL. I also want to confirm if I really want to delete this and
test("is true | false | unknown expressions").Uh oh!
There was an error while loading. Please reload this page.
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.
No, @beliefer . You are confused with Scala DSL and SQL.
This is
sql/catalyst/dslwhich providing Scala API. This is never ANSI SQL.SQL Standard doesn't have
def isNotUnknown. :)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 for your prompt. I am confused indeed and clear now.