Skip to content
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

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

wojustme
Copy link
Contributor

No description provided.

@wojustme wojustme force-pushed the issue_4980 branch 4 times, most recently from 63ce2c0 to d075287 Compare January 16, 2022 12:59
/** Null-safe "&lt;=&gt;" equal operator used by MySQL, for example
* {@code 1<=>NULL}. */
@LibraryOperator(libraries = { MYSQL })
public static final SqlOperator NULL_SAFE_EQUAL =
Copy link
Contributor

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 ?

Copy link
Contributor Author

@wojustme wojustme Jan 17, 2022

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.

Copy link
Contributor

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)

Copy link
Contributor Author

@wojustme wojustme Jan 18, 2022

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@wojustme wojustme Jan 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NobiGo

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)?

@wojustme wojustme force-pushed the issue_4980 branch 2 times, most recently from 7af3afe to 09f1495 Compare January 17, 2022 11:44
@wojustme wojustme changed the title [CALCITE-4980] Babel parser support MySQL NULL-safe equal operator '<=>' (xurenhe) [CALCITE-4980] Babel parser support MySQL NULL-safe equal operator '<=>' (xurenhe&&DuanXiong) Jan 25, 2022
@NobiGo
Copy link
Contributor

NobiGo commented Jan 25, 2022

@wojustme Because refactoring tests in CALCITE-4885, So please fix the conflicts and the typo above.

Copy link
Contributor

@NobiGo NobiGo left a 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.

@@ -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`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equals to ?

@@ -1203,13 +1203,13 @@ The operator precedence and associativity, highest to lowest.
| * / % &#124;&#124; | left
| + - | left
| BETWEEN, IN, LIKE, SIMILAR, OVERLAPS, CONTAINS etc. | -
| < > = <= >= <> != | left
| < > = <= >= <> != <=> | left
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I format it.

Copy link
Contributor

@NobiGo NobiGo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@NobiGo NobiGo merged commit 10e8534 into apache:master Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants