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-9134] [table] upgrade Calcite dependency to 1.17 #6484
Conversation
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 @suez1224. I added some comments.
@@ -20,7 +20,10 @@ package org.apache.flink.table.catalog | |||
|
|||
import java.util.{Collection => JCollection, Collections => JCollections, LinkedHashSet => JLinkedHashSet, Set => JSet} | |||
|
|||
import com.google.common.collect.ImmutableSet | |||
import jdk.nashorn.internal.ir.annotations.Immutable |
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.
Remove unused import.
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.
done
|
||
override def getType(s: String): RelProtoDataType = null | ||
|
||
override def getTypeNames: JSet[String] = ImmutableSet.of() |
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.
We should try to avoid guava. Use java.util.Collections#unmodifiableSet
instead.
import static org.apache.calcite.sql.SqlUtil.stripAs; | ||
|
||
/** | ||
* THIS FILE HAS BEEN COPIED FROM THE APACHE CALCITE PROJECT UNTIL CALCITE-2440 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.
Could you mention which test would fail if we remove this class?
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.
added
|
||
// create a LogicalCalc that computes the complex aggregates and forwards the window properties | ||
relBuilder.project(exprs, oldAgg.getRowType.getFieldNames) | ||
override def newCalcRel(relBuilder: RelBuilder, rowType: RelDataType, exprs: util.List[RexNode]) { |
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 format the code again and add some inline comments to know what is happening here. Add :Unit
as well.
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.
done
@@ -161,7 +161,7 @@ class GroupWindowTest extends TableTestBase { | |||
"rowtime('w$) AS w$rowtime", | |||
"proctime('w$) AS w$proctime") | |||
), | |||
term("select", "EXPR$0", "DATETIME_PLUS(w$end, 60000) AS EXPR$1") | |||
term("select", "EXPR$0", "+(w$end, 60000) AS EXPR$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.
Do you know the reason for this change? Why is DATETIME_PLUS
now equivalent to +
? It is not deprecated. Can we replace all occurrences of this constant in our 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.
@twalthr code relevant is around CodeGenerator#L769
and I think +
is equivalent to DATETIME_PLUS
here and below.
However, I see no reason for this change. Not only DATETIME_PLUS
works as expected, but also DATETIME_PLUS
is more clear than bare +
. How can one know (w$end, 60000)
is about DATETIME
without take a near look.
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.
FYI, code around CodeGenerator#L769
like:
case PLUS | DATETIME_PLUS if isTemporal(resultType) =>
val left = operands.head
val right = operands(1)
requireTemporal(left)
requireTemporal(right)
generateTemporalPlusMinus(plus = true, nullCheck, left, right, config)
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 changed in https://issues.apache.org/jira/browse/CALCITE-2188. DATETIME_PLUS operator is not equal to PLUS operator, they just somehow share the same name "+" in plan after the PR. I can reach out to Calcite community to see if it makes sense to revert it back, I agree that using "DATETIME_PLUS" is more clear.
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 research. @suez1224 if you find time, you could discuss this in the Calcite community again. I find it a bit confusing to have the same same string for different SQL operators. But it is not a blocker for this PR.
- incoporate calcite change in DATETIME_PLUS operator. - fix unittests. - fix SqlToRelConverter in Flink repo.
@twalthr addressed the comments. Let me know what you think. |
@suez1224 Hi, thanks for your PR. Only one question from my side: do we have any good ideas or plans about how to remove |
@hequn8128 I'm not aware of any plans. Actually, I'm wondering if the community could just remove the logic in AuxiliaryConverter and just return the plan unmodified. Every project could implement their own conversion logic. |
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 update @suez1224.
+1 from my side to merge this.
merged |
@suez1224 please include the issue in commit such as
Otherwise no one knows what happened in this commit:
|
What is the purpose of the change
upgrade Calcite dependency to 1.17
Brief change log
Verifying this change
This change is already covered by existing tests
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation