-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CALCITE-4980] Babel parser support MySQL NULL-safe equal operator '<=>' (xurenhe&&DuanXiong) #2692
Conversation
63ce2c0
to
d075287
Compare
/** Null-safe "<=>" equal operator used by MySQL, for example | ||
* {@code 1<=>NULL}. */ | ||
@LibraryOperator(libraries = { MYSQL }) | ||
public static final SqlOperator NULL_SAFE_EQUAL = |
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 think The NULL_SAFE_EQUAL is IS_NOT_DISTINCT_FROM. Not belong to. So
public static final SqlOperator NULL_SAFE_EQUAL = SqlStdOperatorTable.IS_NOT_DISTINCT_FROM;
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.
@NobiGo
Yes, you are right.
But I need change operator's name to '<=>', so, I create an object of 'SqlBinaryOperator' to define Operator of '<=>'.
Thanks.
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 do we need to change the operator's name? If we use the SqlStdOperatorTable.IS_NOT_DISTINCT_FROM directly, Then can support parse and execute. Now only can support parse. If I miss something please let me know.
and Add another parse test cases for (a, b) <=> (x, y)
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.
@NobiGo
When using SqlStdOperatorTable#IS_NOT_DISTINCT_FROM, 'X
<=> 3' will return 'X
IS NOT DISTINCT FROM 3'.
I think it destroys the user's original input.
By the way, I didn't know why we need the test of (a, b) <=> (x, y)
.
Please point me, Thanks.
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.
According to MySQL '<=>' . We should cover it.
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.
Please don't force fush commit, until we have a final state.
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.
Ok, got it.
In my project, I didn't meet these complex scenes.
I will add some related test cases.
Thanks a lot.
I debug it, I found realizing (a, b) <=> (x, y)
in current framework of binaryOperatorsTokens is too difficult.
(a, b) <=> (x, y)
will parse to ROW(a, b) <=> ROW(x, y)
, is it the correct semantics?
So, should me define a scalable token to support (a, b) <=> (x, y)
?
babel/src/test/java/org/apache/calcite/test/BabelParserTest.java
Outdated
Show resolved
Hide resolved
7af3afe
to
09f1495
Compare
@wojustme Because refactoring tests in CALCITE-4885, So please fix the conflicts and the typo above. |
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.
Some small typos need fix.
site/_docs/reference.md
Outdated
@@ -2513,6 +2515,7 @@ semantics. | |||
| C | Operator syntax | Description | |||
|:- |:-----------------------------------------------|:----------- | |||
| p | expr :: type | Casts *expr* to *type* | |||
| m | expr1 <=> expr2 | Whether *expr1* equal to *expr2*, but returns true if both operands are `NULL`, and false if one operand is `NULL` (similar to `IS NOT DISTINCT FROM`) |
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.
equals to ?
site/_docs/reference.md
Outdated
@@ -1203,13 +1203,13 @@ The operator precedence and associativity, highest to lowest. | |||
| * / % || | left | |||
| + - | left | |||
| BETWEEN, IN, LIKE, SIMILAR, OVERLAPS, CONTAINS etc. | - | |||
| < > = <= >= <> != | left | |||
| < > = <= >= <> != <=> | left |
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.
Please trims extra spaces? The left value has translation.
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.
ok, I format it.
…=>' (xurenhe&&DuanXiong)
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
No description provided.