-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[FLINK-35854][table] Upgrade Calcite version to 1.35.0 #26547
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
base: master
Are you sure you want to change the base?
Conversation
[INFO] | +- org.apache.calcite.avatica:avatica-core:jar:1.23.0:compile | ||
[INFO] | +- org.apiguardian:apiguardian-api:jar:1.1.2:compile | ||
[INFO] | +- org.checkerframework:checker-qual:jar:3.12.0:compile | ||
[INFO] | +- org.checkerframework:checker-qual:jar:3.10.0:compile |
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.
this is not related to this commit, however seems at some point the version was downgraded in Flink.
There is no critical changes, so should be ok
|
||
@Override | ||
public DataType getResultType() { | ||
return DataTypes.BOOLEAN(); |
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.
This is probably the main question: should we have it for different types or boolean is enough?
So far in existing tests there is only boolean in use
@flinkbot run azure |
@@ -3061,34 +3061,6 @@ SqlNode SqlReset() : | |||
} | |||
} | |||
|
|||
|
|||
/** Parses a TRY_CAST invocation. */ |
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.
Since now TRY_CAST
comes with Calcite https://issues.apache.org/jira/browse/CALCITE-4771
@@ -168,8 +168,8 @@ public SqlLibrary semantics() { | |||
} | |||
|
|||
@Override | |||
public boolean allowCoercionStringToArray() { | |||
return SqlConformanceEnum.DEFAULT.allowCoercionStringToArray(); | |||
public boolean allowLenientCoercion() { |
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.
Suddenly was just renamed in Calcite apache/calcite@b042094
0bab0b8
to
6c34459
Compare
@@ -293,6 +292,8 @@ | |||
"DATETIME_DIFF" | |||
"DATETIME_INTERVAL_CODE" | |||
"DATETIME_INTERVAL_PRECISION" | |||
"DAYOFWEEK" |
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 am curious why these 2 re in this list and not in nonReservedKeywordsToAdd.
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.
keep in sync with Calcite version https://github.com/apache/calcite/blob/75750b78b5ac692caa654f506fc1515d4d3991d6/core/src/main/codegen/templates/Parser.jj#L7963
@@ -224,7 +224,6 @@ | |||
"RESUME" | |||
"TABLES" | |||
"TIMESTAMP_LTZ" | |||
"TRY_CAST" |
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 am curious why TRY_CAST is removed as a keyword. I had assumed it would still be a keyword but Calcite would now provide the implementation.
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.
because it was added to keywords on Calcite level, no need to add it one more time
e616ba0
to
b8a8b8b
Compare
af327eb
to
44d710b
Compare
a8b5103
to
fc3c7e7
Compare
* <li>Added in FLINK-34057, FLINK-34058, FLINK-34312: Lines 452 ~ 469 | ||
* </ol> | ||
*/ | ||
class AggConverter implements SqlVisitor<Void> { |
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 result of this commit apache/calcite@568ce12
where SqlToRelConverter
was splitted into 2 classes
|
||
/** Rules that determine whether a type is castable from another type. */ | ||
public class FlinkCalciteTableMappingRule implements SqlTypeMappingRule { | ||
private static final FlinkCalciteTableMappingRule INSTANCE; |
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 behavior of SqlTypeCoercionRule
was changed (https://issues.apache.org/jira/browse/CALCITE-5662) and started leading to a number of failures in CastFunctionITCase
.
New mapping rule makes it working in same way as before
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.
Thank you for this PR @snuyanzin. This must have been painful work. I added some comments.
* <li>Added in FLINK-32474: Lines 3046 ~ 3080 | ||
* <li>Added in FLINK-34312: Lines 5827 ~ 5838 | ||
* <li>Added in FLINK-34057, FLINK-34058, FLINK-34312: Lines 6285 ~ 6303 | ||
* <li>Added in FLINK-29081, FLINK-28682, FLINK-33395: Lines 673 ~ 690 |
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.
Thank you for updating all these lines. Very helpful, but I'm sure also a lot of work!
SqlStdOperatorTable.POSITION.createCall( | ||
SqlParserPos.ZERO, call.operand(1), call.operand(0)))); | ||
|
||
// "INSTR(string, substring, position, occurrence) is equivalent to |
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.
do we need to document those function synonyms?
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.
don't think so
existing position
, instr
are covered in doc
with other args just fail with validation
@@ -8001,6 +8003,8 @@ SqlPostfixOperator PostfixRowOperator() : | |||
| < DATETIME_INTERVAL_PRECISION: "DATETIME_INTERVAL_PRECISION" > | |||
| < DATETIME_TRUNC: "DATETIME_TRUNC" > | |||
| < DAY: "DAY" > | |||
| < DAYOFWEEK: "DAYOFWEEK" > |
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.
update documentation, do we also support those in runtime code? or at least throw a proper error message?
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.
it's already covered in doc
flink/docs/data/sql_functions.yml
Lines 628 to 633 in a4e3084
- sql: DAYOFYEAR(date) | |
description: Returns the day of a year (an integer between 1 and 366) from SQL date. Equivalent to EXTRACT(DOY FROM date). E.g., DAYOFYEAR(DATE '1994-09-27') returns 270. | |
- sql: DAYOFMONTH(date) | |
description: Returns the day of a month (an integer between 1 and 31) from SQL date. Equivalent to EXTRACT(DAY FROM date). E.g., DAYOFMONTH(DATE '1994-09-27') returns 27. | |
- sql: DAYOFWEEK(date) | |
description: Returns the day of a week (an integer between 1 and 7) from SQL date. Equivalent to EXTRACT(DOW FROM date). E.g., DAYOFWEEK(DATE '1994-09-27') returns 3. |
...nk-table-planner/src/main/java/org/apache/calcite/sql/type/FlinkCalciteTableMappingRule.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
/** Built-in Long Literal aggregate function. */ | ||
public static class LongLiteralAggFunction extends LiteralAggFunction { |
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 INT? Are byte and short ever called?
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 added for int as well
however we don't have any test calling anything else except for boolean
|
||
@Override | ||
public UnresolvedReferenceExpression[] aggBufferAttributes() { | ||
return new UnresolvedReferenceExpression[] {literalAgg}; |
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.
Do we actually need to use any state? Can't this be empty array?
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 like with current framework it is not possible to do it...
At least this test requires it JoinWithoutKeyITCase#testNonKeySemi
What is the purpose of the change
Upgrade Calcite to 1.35.0
Brief change log
There are several major changes done in Calcite 1.35.0
About commits
3242726 - Update poms and NOTICE files
bec22cc - Remove RelBuilder
2161225 - Remove SqlTimestampAddFunction
f7c5c96 - Remove CompositeSingleOperandTypeChecker
19cb1e3 - Update Calcite classes to be synced with https://github.com/apache/calcite/releases/tag/calcite-1.35.0
1d284f2 - Update Flink classes
9ba9ab6 - Add FlinkCalciteTableMappingRule
929ce63 - Update plans
985e500 - Update SqlNodeToCallOperationTest
0faf592 - Add LiteralAggFunction
acc7307 - Update plans after LiteralAggFunction
4dc67fd - Update JoinTest.testJoinUDTFWithInvalidJoinHint
Verifying this change
existing tests
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: ( no)Documentation