yiyutian1 commented on code in PR #30240:
URL: https://github.com/apache/flink/pull/30240#discussion_r4790131753
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/agg/batch/WindowCodeGenerator.scala:
##########
@@ -764,7 +763,7 @@ object WindowCodeGenerator {
new JTuple2[JLong, JLong](windowSize, slideSize)
}
- def asLong(expr: Expression): Long = extractValue(expr, classOf[JLong]).get()
+ def asLong(expr: ValueLiteralExpression): Long =
AggregateUtil.toDuration(expr).toMillis
Review Comment:
I took a look too. `extractValue` is fine. It just calls
`ValueLiteralExpression.getValueAs`, which only converts toward the `java.time`
types (Duration, Period, LocalDate, ...). There's no `Duration` to `Long` path,
so a literal restored from a compiled plan comes back empty when asked for
`JLong`, and `.get(`) throws. Asking for `Duration` and calling `.toMillis` is
the fix, same as `AggregateUtil.toDuration` on the streaming side.
The narrower parameter type isn't needed, but it's harmless: size and slide
on `TumblingGroupWindow/SlidingGroupWindow` are already
`ValueLiteralExpression`, and all callers are in this file. Either option works
for me:
1. Keep it as is and reuse `AggregateUtil.toDuration`.
2. Keep `asLong(expr: Expression)` and use `extractValue(expr,
classOf[Duration]).get().toMillis` for a smaller diff.
--
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]