Minhas A v created FLINK-41769:
----------------------------------
Summary: WindowCodeGenerator.asLong fails with
NoSuchElementException for a window size restored from a compiled plan
Key: FLINK-41769
URL: https://issues.apache.org/jira/browse/FLINK-41769
Project: Flink
Issue Type: Bug
Components: Table SQL / Planner
Reporter: Minhas A v
Batch window aggregates read the window size and slide with
{{{}WindowCodeGenerator.asLong(Expression){}}}, which calls
{{{}extractValue(expr, classOf[JLong]).get(){}}}.
A window size restored from a compiled plan is a {{ValueLiteralExpression}}
holding a {{Duration}} ({{{}LogicalWindowJsonDeserializer{}}} builds it from
the stored value, e.g. {{{}PT15M{}}}). {{ValueLiteralExpression}} can convert a
{{Long}} to a {{{}Duration{}}}, but not a {{Duration}} to a {{{}Long{}}}, so
{{Optional.get()}} throws {{{}NoSuchElementException: No value present{}}}.
It is not reachable on master today: {{BatchExecHashWindowAggregate}} and
{{BatchExecSortWindowAggregate}} have no {{@ExecNodeMetadata}} (see FLINK-36721
and FLINK-36722), so their plans cannot be saved or loaded. It becomes
reachable once those are added.
Reproducer:
{code:java}
ValueLiteralExpression size = new
ValueLiteralExpression(Duration.ofMinutes(15));
WindowCodeGenerator.asLong(size); // java.util.NoSuchElementException: No value
present
{code}
Proposed fix: read the literal with AggregateUtil.toDuration(literal).toMillis,
as the streaming window nodes do. This accepts both a Long (freshly planned)
and a Duration (restored).
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)