Nic Townsend created FLINK-38162: ------------------------------------ Summary: Use of SQL functions with time attributes causes downstream temporal functions to fail Key: FLINK-38162 URL: https://issues.apache.org/jira/browse/FLINK-38162 Project: Flink Issue Type: Bug Components: Table SQL / Planner Affects Versions: 1.20.0 Reporter: Nic Townsend
In the Flink docs for window join - [https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/sql/queries/window-join/#innerleftrightfull-outer] - the outer join example does not include the use of {{window_time.}} This means that you cannot perform a window aggregate for example on the result of the join - perhaps for example you want to count how many rows came from the left, right, or both in a given window. If you use the {{COALESCE}} like in the example, then although a {{DESCRIBE}} will show {code:java} +----------+------------------------+------+-----+--------+----------------------------------+ | name | type | null | key | extras | watermark | +----------+------------------------+------+-----+--------+----------------------------------+ | window_time | TIMESTAMP(3) *ROWTIME* | true | | | | {code} it will not work with a Window TVF and throws an error that {{window_time}} is not a time attribute. Even worse - if you build the following statement set (pseduo): * CREATE left table * CREATE right table * CREATE temporary view joined <WINDOW OUTER JOIN of left,right> * CREATE temporary view aggregate <WINDOW AGGREGATE of joined> * CREATE blackhole joined_sink <schema matches joined> * CREATE blackhole aggregate_sink <schema matches aggregate> * INSERT into joined_sink * INSERT into aggregate_sink Then you end up with a stack trace from the planner of: {code:java} java.lang.RuntimeException: Error while applying rule ProjectToCalcRule, args [rel#7305:LogicalProject.NONE.any.None: 0.[NONE].[NONE](input=RelSubset#7304,exprs=[$4, $5, $6, $0, $1])] at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:250) ~[flink-table-planner_2.12-1.20.1.jar:1.20.1] [...] Caused by: java.lang.IllegalArgumentException: Type mismatch: rel rowtype: RecordType(TIMESTAMP(3) windowStartTime, TIMESTAMP(3) windowEndTime, TIMESTAMP(3) windowResultTime, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" user_id, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" product_id) NOT NULL equiv rowtype: RecordType(TIMESTAMP(3) windowStartTime, TIMESTAMP(3) windowEndTime, TIMESTAMP(3) *ROWTIME* windowResultTime, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" user_id, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" product_id) NOT NULL Difference: windowResultTime: TIMESTAMP(3) -> TIMESTAMP(3) *ROWTIME* {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)