You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Timo Theusner (Jira)" <ji...@apache.org> on 2026/08/03 09:28:00 UTC
[jira] [Updated] (FLINK-40271) Group window properties produce invalid SQL in QueryOperation#asSerializableString
[ https://issues.apache.org/jira/browse/FLINK-40271?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Timo Theusner updated FLINK-40271:
----------------------------------
Description:
Table API group-window properties ({{{}$("w").rowtime(){}}}, {{{}$("w").proctime(){}}}, {{{}$("w").start(){}}}, {{$("w").end())}} are not translated to the corresponding windowing-TVF output columns when a {{WindowAggregateQueryOperation}} is serialized back to SQL. Instead, the window alias is emitted as if it were a column reference, producing SQL that does not parse.
Replication:
{code:java}
Table t = env.from("orders")
.window(Tumble.over(lit(1).minutes()).on($("ts")).as("w"))
.groupBy($("product_id"), $("w"))
.select($("product_id"), $("w").start(), $("w").end(), $("w").rowtime(), $("price").sum());
String sql = t.getQueryOperation()
.asSerializableString(DefaultSqlFactory.INSTANCE);
env.sqlQuery(sql); // fails
{code}
Corresponding error message:
{code:java}
org.apache.flink.table.api.ValidationException: SQL validation failed. Column 'w' not found in any table {code}
was:
Table API group-window properties ({{{}$("w").rowtime(){}}}, {{{}$("w").proctime(){}}}, {{{}$("w").start(){}}}, {{$("w").end())}} are not translated to the corresponding windowing-TVF output columns when a {{WindowAggregateQueryOperation}} is serialized back to SQL. Instead, the window alias is emitted as if it were a column reference, producing SQL that does not parse. This has the effect that the example from the official docs do not work:
{code:java}
Table t = env.from("orders")
.window(Tumble.over(lit(1).minutes()).on($("ts")).as("w"))
.groupBy($("product_id"), $("w"))
.select($("product_id"), $("w").start(), $("w").end(), $("w").rowtime(), $("price").sum());
String sql = t.getQueryOperation()
.asSerializableString(DefaultSqlFactory.INSTANCE);
env.sqlQuery(sql); // fails
{code}
Corresponding error message:
{code:java}
org.apache.flink.table.api.ValidationException: SQL validation failed. Column 'w' not found in any table {code}
> Group window properties produce invalid SQL in QueryOperation#asSerializableString
> ----------------------------------------------------------------------------------
>
> Key: FLINK-40271
> URL: https://issues.apache.org/jira/browse/FLINK-40271
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / API
> Reporter: Timo Theusner
> Assignee: Timo Theusner
> Priority: Major
>
> Table API group-window properties ({{{}$("w").rowtime(){}}}, {{{}$("w").proctime(){}}}, {{{}$("w").start(){}}}, {{$("w").end())}} are not translated to the corresponding windowing-TVF output columns when a {{WindowAggregateQueryOperation}} is serialized back to SQL. Instead, the window alias is emitted as if it were a column reference, producing SQL that does not parse.
> Replication:
> {code:java}
> Table t = env.from("orders")
> .window(Tumble.over(lit(1).minutes()).on($("ts")).as("w"))
> .groupBy($("product_id"), $("w"))
> .select($("product_id"), $("w").start(), $("w").end(), $("w").rowtime(), $("price").sum());
> String sql = t.getQueryOperation()
> .asSerializableString(DefaultSqlFactory.INSTANCE);
> env.sqlQuery(sql); // fails
> {code}
> Corresponding error message:
> {code:java}
> org.apache.flink.table.api.ValidationException: SQL validation failed. Column 'w' not found in any table {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)