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

[FLINK-11921][table] Upgrade to calcite 1.19 #8324

Closed
wants to merge 2 commits into from

Conversation

walterddr
Copy link
Contributor

@walterddr walterddr commented Apr 30, 2019

What is the purpose of the change

This change upgrades apache calcite dependencies to 1.19.0 release.

Brief change log

  • Updated pom.xml file to include calcite 1.19.0
  • Updated all test cases that includes literals which now includes type in digest.
  • Updated the 2 pull-in files DateTimeUtils and AuxiliaryConverter and updated the depending calcite JIRAs which will eventually allow us to remove these two pull-ins.
  • Updated the FlinkLogicalTableSourceScan to include a new computeDigest override, this allows predicator push-down rules like PushFilterIntoTableSourceScanRule and PushProjectIntoTableSourceScanRule to find correct entry in digestToRelMap (see CALCITE-2454, and CALCITE PR #1002)

Verifying this change

  • This change is already covered by existing tests
  • Verified via mvn dependeny:tree that no extra dependencies were pulled in.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): yes
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? n/a

@flinkbot
Copy link
Collaborator

flinkbot commented Apr 30, 2019

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❗ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

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 commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@walterddr
Copy link
Contributor Author

@flinkbot attention @twalthr

@rmetzger rmetzger requested a review from twalthr May 2, 2019 04:40
@walterddr
Copy link
Contributor Author

@flinkbot attention @wuchong

@walterddr
Copy link
Contributor Author

@wuchong can you also help take a look at the upgrade? Thanks

@rmetzger rmetzger requested a review from wuchong May 11, 2019 11:41
@walterddr
Copy link
Contributor Author

@flinkbot attention @KurtYoung

@KurtYoung
Copy link
Contributor

@danny0405 Could you help to review this PR?

@danny0405
Copy link
Contributor

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

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 ?

Copy link
Contributor Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Useless comments

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

@danny0405 danny0405 May 16, 2019

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Useless comments

Copy link
Contributor Author

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.

Copy link
Contributor

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

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.

Copy link
Contributor Author

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);
}
Copy link
Contributor

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 ?

Copy link
Contributor Author

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:
Copy link
Contributor

@danny0405 danny0405 May 15, 2019

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.

Copy link
Contributor Author

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

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

@walterddr walterddr left a 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
Copy link
Contributor Author

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.
Copy link
Contributor Author

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;
Copy link
Contributor Author

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;
Copy link
Contributor Author

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

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
Copy link
Contributor Author

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);
}
Copy link
Contributor Author

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);
Copy link
Contributor Author

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:
Copy link
Contributor Author

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.

@walterddr
Copy link
Contributor Author

walterddr commented May 16, 2019

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

  1. commented it out makes it easier for future contributor to maintain the code - I had to dig deep to understand which part of the code is needed to comment out by running multiple tests because that previous removal was not traceable.
  2. ideally speaking we shouldn't copy and alter calcite/avatica code, this is only to unblock the release until a specific CALCITE JIRA has been fix - the previous version of the DateTimeUtils has not been updated since 3,4 versions ago. I think it make sense to upgrade it to the one that currently calcite-core depends on.

What do you guys think? I am open up for any changes to the policy as long as we all agree on the process.

Rong Rong added 2 commits May 21, 2019 08:44
1. adding in CALCITE pull in file comments and update modification notes
2. also fix CALCITE-2454, PR apache#1002 and fix scalastyle
@walterddr
Copy link
Contributor Author

@fhueske @twalthr could you take a look?

@danny0405
Copy link
Contributor

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.

@walterddr
Copy link
Contributor Author

walterddr commented May 28, 2019

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

@danny0405
Copy link
Contributor

@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.

@walterddr
Copy link
Contributor Author

close this pull request and recreate new one once calcite 1.20 releases

@walterddr walterddr closed this Jun 7, 2019
@danny0405
Copy link
Contributor

@walterddr The Apache Calcite 1.20.0 has been released, can you do the upgrade now ?

@walterddr
Copy link
Contributor Author

thanks for the reminder @danny0405. will try to take a look and create another PR asap.

@walterddr walterddr deleted the FLINK-11921 branch July 10, 2019 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants