Izeren commented on code in PR #28858:
URL: https://github.com/apache/flink/pull/28858#discussion_r3749791539
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/over/RangeBoundComparatorCodeGenerator.scala:
##########
@@ -135,16 +135,25 @@ class RangeBoundComparatorCodeGenerator(
inputValue: String,
currentValue: String,
parentCtx: CodeGeneratorContext): String = {
- val (realBoundValue, realKeyType) = keyType.getTypeRoot match {
- case LogicalTypeRoot.DATE =>
- // The constant about time is expressed based millisecond unit in
calcite, but
- // the field about date is expressed based day unit. So here should
keep the same unit for
- // comparator.
+ val (realBoundValue, realKeyType) =
+ if (keyType.is(LogicalTypeFamily.TIMESTAMP)) {
+ (bound, new BigIntType())
+ } else if (keyType.is(LogicalTypeFamily.TIME)) {
+ (bound, new IntType())
+ } else if (keyType.is(LogicalTypeRoot.DATE)) {
+ // Calcite bound is in millis; DATE field is in days
(bound.asInstanceOf[Long] / DateTimeUtils.MILLIS_PER_DAY, new
IntType())
- case LogicalTypeRoot.TIME_WITHOUT_TIME_ZONE => (bound, new IntType())
- case LogicalTypeRoot.TIMESTAMP_WITHOUT_TIME_ZONE => (bound, new
BigIntType())
- case _ => (bound, keyType)
- }
+ } else {
+ (bound, keyType)
+ }
+
+ val (realInputValue, realCurrentValue) =
+ if (keyType.is(LogicalTypeFamily.TIMESTAMP)) {
+ // TypeFamily covers all TIMESTAMP variants; .getMillisecond() yields
epoch millis for ExprCodeGenerator
+ (s"$inputValue.getMillisecond()", s"$currentValue.getMillisecond()")
Review Comment:
That is a good spot, I will push a microsecond precision version
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]