Nico Kruber created FLINK-20061:
----------------------------------- Summary: Row constructor unsupported in aggregation function Key: FLINK-20061 URL: https://issues.apache.org/jira/browse/FLINK-20061 Project: Flink Issue Type: Bug Components: Table SQL / API Affects Versions: 1.11.2 Reporter: Nico Kruber I was trying to use {{ROW}} in a user-defined aggregate function in a query like this: {code} SELECT `id`, HOP_END(`timestamp`, INTERVAL '10' MINUTE, INTERVAL '1' MINUTE) AS `window_end`, RowMaxv0(`amount`, ROW(`timestamp`, `amount`, `payload`)) AS `max_amount` FROM `input` GROUP BY HOP(`timestamp`, INTERVAL '10' MINUTE, INTERVAL '1' MINUTE), `id`; {code} Eventually this resulted in an "unsupported" exception from Calcite: {code} Exception in thread "main" org.apache.flink.table.api.ValidationException: SQL validation failed. null at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:146) at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:108) at org.apache.flink.table.planner.operations.SqlToOperationConverter.convert(SqlToOperationConverter.java:187) at org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:78) at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeSql(TableEnvironmentImpl.java:684) at com.ververica.platform.sql.functions.RowMaxv0.main(RowMaxv0.java:93) Caused by: java.lang.UnsupportedOperationException at org.apache.calcite.sql.validate.SqlValidatorImpl.validateColumnListParams(SqlValidatorImpl.java:5689) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:268) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:218) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5858) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5845) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1800) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1785) at org.apache.calcite.sql.SqlAsOperator.deriveType(SqlAsOperator.java:133) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5858) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5845) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1800) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1785) at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:481) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4255) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3523) at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60) at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1110) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1084) at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:232) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1059) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:766) at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.org$apache$flink$table$planner$calcite$FlinkPlannerImpl$$validate(FlinkPlannerImpl.scala:141) ... 5 more {code} A workaround for this is to go via a subquery like the following but ultimately, this should result in the same thing (a simple projection). {code} SELECT `id`, HOP_END(`timestamp`, INTERVAL '10' MINUTE, INTERVAL '1' MINUTE) AS `window_end`, RowMaxv0(`amount`, `row`) AS `max_amount` FROM (SELECT `id`, `timestamp`, `amount`, ROW(`timestamp`, `amount`, `payload`) AS `row` FROM `input`) GROUP BY HOP(`timestamp`, INTERVAL '10' MINUTE, INTERVAL '1' MINUTE), `id` {code} -- This message was sent by Atlassian Jira (v8.3.4#803005) |
Free forum by Nabble | Edit this page |