[ 
https://issues.apache.org/jira/browse/FLINK-41571?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hao Li reassigned FLINK-41571:
------------------------------

    Assignee: Hanyu Zheng

> TIMESTAMPDIFF between TIMESTAMP_LTZ and DATE or TIMESTAMP passes validation 
> but fails in code generation
> --------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-41571
>                 URL: https://issues.apache.org/jira/browse/FLINK-41571
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 2.3.0
>            Reporter: Hanyu Zheng
>            Assignee: Hanyu Zheng
>            Priority: Major
>             Fix For: 2.3.0
>
>
> TIMESTAMPDIFF with a TIMESTAMP_LTZ argument and a DATE or TIMESTAMP argument 
> passes validation, then fails during code generation with a CodeGenException. 
> This happens in both batch and streaming mode.
> {code:sql}
> CREATE TABLE T (d DATE, ltz TIMESTAMP_LTZ(3)) WITH ('connector' = 'datagen');
> SELECT TIMESTAMPDIFF(DAY, d, ltz) FROM T;
> {code}
> {noformat}
> org.apache.flink.table.planner.codegen.CodeGenException: TIMESTAMP_LTZ only 
> supports diff between the same type.
> {noformat}
> ScalarOperatorGens.generateTemporalPlusMinus sends every (TIMESTAMP_LTZ, 
> DATETIME) pair to generateTimestampLtzMinus. That method only handles LTZ 
> minus LTZ and throws for any other pair. The same rule makes other shapes end 
> in the generic "Unsupported temporal arithmetic." error.
> Either support the mixed case by converting the DATE or TIMESTAMP operand to 
> TIMESTAMP_LTZ in the session time zone, or reject it in the validator with a 
> message that names both types and suggests a CAST.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to