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
[FLINK-11921][table] Upgrade to calcite 1.19 #8324
Conversation
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
@wuchong can you also help take a look at the upgrade? Thanks |
@flinkbot attention @KurtYoung |
@danny0405 Could you help to review this PR? |
Sure, i will try to finish this reviewing AFAIK. |
|
||
[INFO] +- org.apache.calcite:calcite-core:jar:1.18.0:compile | ||
[INFO] +- org.apache.calcite:calcite-core:jar:1.19.0:compile | ||
[INFO] | +- org.apache.calcite.avatica:avatica-core:jar:1.13.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.
calcite-avatica
1.15.0 has released recently, do we have plan to upgrade ?
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 we will use whatever version calcite-core
is using. thus avatica 1.15.0 will be upgraded when upgrade to calcite 1.20.0
// int d = da - (m + 4) * 153 / 5 + 122; | ||
// int year = y - 4800 + (m + 2) / 12; | ||
// int month = (m + 2) % 12 + 1; | ||
// int day = d + 1; |
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.
Useless comments
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 explicitly commented out on purpose.
int m = (da * 5 + 308) / 153 - 2; | ||
// number of days elapsed since day 1 of the month | ||
int d = da - (m + 4) * 153 / 5 + 122; | ||
int year = y - 4800 + (m + 2) / 12; |
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 have no idea whether this logic is right or not, let's just add enough Unit tests.
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 copied from avatica 1.14.0 release
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 didn't see the necessity to copy a code snippet and comments it out. If we comments out existed code, i agree to keep these comments, but they are very new codes.
// + 365 * y | ||
// + y / 4 | ||
// - y / 100 | ||
// + y / 400 |
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.
Useless comments
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.
these lines are explicitly comment out on purpose.
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.
Let's just remove these useless comments, we can add them back if we really need them in the future, for current code base, these comments are really confusing.
* higher). */ | ||
private interface OffsetDateTimeHandler { | ||
boolean isOffsetDateTime(Object o); | ||
String stringValue(Object o); |
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 really need this interface stringValue
? The two implementations: one is static and one throws an exception, i didn't see why we should keep this.
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 copied from avactica 1.14.0 release
/** Returns the value of a {@code OffsetDateTime} as a string. */ | ||
public static String offsetDateTimeValue(Object o) { | ||
return OFFSET_DATE_TIME_HANDLER.stringValue(o); | ||
} |
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.
Does this mean if we do not have class "java.time.OffsetDateTime", we would always got an exception ?
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 copied from avactica 1.14.0 release
// return rexBuilder.makeCall( | ||
// SqlStdOperatorTable.PLUS, e, | ||
// ((RexCall) groupCall).operands.get(2)); | ||
// default: |
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.
Let's just keep these comments.
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.
good point. I should kept the comments. thanks for reminder.
private static int getIso8601WeekNumber(int julian, int year, int month, int day) { | ||
long fmofw = firstMondayOfFirstWeek(year); | ||
if (month == 12 && day > 28) { | ||
if (31 - day + 4 > 7 - ((int) floorMod(julian, 7) + 1) |
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.
Although the Calcite bug may be fixed in future, lets's add UT for these transformation functions for our current code base.
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.
these lines are copied from avatica 1.14.0 release
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 the review @danny0405 . please see my comments inline. I will update the change accordingly.
|
||
[INFO] +- org.apache.calcite:calcite-core:jar:1.18.0:compile | ||
[INFO] +- org.apache.calcite:calcite-core:jar:1.19.0:compile | ||
[INFO] | +- org.apache.calcite.avatica:avatica-core:jar:1.13.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.
I think we will use whatever version calcite-core
is using. thus avatica 1.15.0 will be upgraded when upgrade to calcite 1.20.0
@@ -26,7 +26,8 @@ | |||
import java.util.TimeZone; | |||
|
|||
/* | |||
* THIS FILE HAS BEEN COPIED FROM THE APACHE CALCITE PROJECT UNTIL CALCITE-1884 IS FIXED. | |||
* THIS FILE HAS BEEN COPIED FROM THE APACHE CALCITE PROJECT UNTIL CALCITE-2989 IS FIXED. |
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.
@danny0405, per the Flink table contribution guideline. when we alter Calcite classes, we need to have a [CALCITE-xxxx]
ticket explained the future consolidation plan. as well as explicitly comment out the changes made on top of the copied Calcite classes.
This class is copied from avatica 1.14.0 release and made only the following lines of changes.
please refer to CALCITE-2989 / FLINK-11935 for more info
// int d = da - (m + 4) * 153 / 5 + 122; | ||
// int year = y - 4800 + (m + 2) / 12; | ||
// int month = (m + 2) % 12 + 1; | ||
// int day = d + 1; |
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 explicitly commented out on purpose.
int m = (da * 5 + 308) / 153 - 2; | ||
// number of days elapsed since day 1 of the month | ||
int d = da - (m + 4) * 153 / 5 + 122; | ||
int year = y - 4800 + (m + 2) / 12; |
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 copied from avatica 1.14.0 release
private static int getIso8601WeekNumber(int julian, int year, int month, int day) { | ||
long fmofw = firstMondayOfFirstWeek(year); | ||
if (month == 12 && day > 28) { | ||
if (31 - day + 4 > 7 - ((int) floorMod(julian, 7) + 1) |
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.
these lines are copied from avatica 1.14.0 release
// + 365 * y | ||
// + y / 4 | ||
// - y / 100 | ||
// + y / 400 |
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.
these lines are explicitly comment out on purpose.
/** Returns the value of a {@code OffsetDateTime} as a string. */ | ||
public static String offsetDateTimeValue(Object o) { | ||
return OFFSET_DATE_TIME_HANDLER.stringValue(o); | ||
} |
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 copied from avactica 1.14.0 release
* higher). */ | ||
private interface OffsetDateTimeHandler { | ||
boolean isOffsetDateTime(Object o); | ||
String stringValue(Object o); |
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 copied from avactica 1.14.0 release
// return rexBuilder.makeCall( | ||
// SqlStdOperatorTable.PLUS, e, | ||
// ((RexCall) groupCall).operands.get(2)); | ||
// default: |
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.
good point. I should kept the comments. thanks for reminder.
thanks for the pointer @danny0405 actually i agree with the guideline @twalthr setup previously to left the code commented out not removed, and kept the java class in sync with the one used in calcite except for the lines we changed. because
What do you guys think? I am open up for any changes to the policy as long as we all agree on the process. |
1. adding in CALCITE pull in file comments and update modification notes 2. also fix CALCITE-2454, PR apache#1002 and fix scalastyle
CALCITE-3055 is a vital regression for VolcanoPlanner, it would be fixed in 1.20.0, i think we should skip 1.19.0 version Calcite, and use 1.20.0 directly. |
@danny0405 hmm. I think that's probably a good idea Considering the light-weighted changes I did for this PR. I suggest we commit this PR's change first and then continue to move on releasing 1.9 with Calcite 1.20.0 if possible. Or I can also commit on top of this PR for 1.20.0, do you know how far away CALCITE-3055 is? Looks like the PR is small and should be merged soon? |
@walterddr CALCITE-3055 has been merged, and Calcite version 1.20 may be released around Mid June, let's just skip 1.19 and use 1.20 directly. |
close this pull request and recreate new one once calcite 1.20 releases |
@walterddr The Apache Calcite 1.20.0 has been released, can you do the upgrade now ? |
thanks for the reminder @danny0405. will try to take a look and create another PR asap. |
What is the purpose of the change
This change upgrades apache calcite dependencies to 1.19.0 release.
Brief change log
DateTimeUtils
andAuxiliaryConverter
and updated the depending calcite JIRAs which will eventually allow us to remove these two pull-ins.FlinkLogicalTableSourceScan
to include a new computeDigest override, this allows predicator push-down rules likePushFilterIntoTableSourceScanRule
andPushProjectIntoTableSourceScanRule
to find correct entry in digestToRelMap (see CALCITE-2454, and CALCITE PR #1002)Verifying this change
mvn dependeny:tree
that no extra dependencies were pulled in.Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: noDocumentation