[ 
https://issues.apache.org/jira/browse/FLINK-22354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17325819#comment-17325819
 ] 

Leonard Xu commented on FLINK-22354:
------------------------------------

[~twalthr] MySQL is 0, Oracle and postgresql is 6, Snowflake is 9, I think in 
big data area, milliseconds is more used, and our watermark alway support to 
milliseconds precision. In the past, many users wrongly using these functions 
but they can still work because the real value returned(code-gened) is in 
millisecond and the rowtime checks isn't strict to 3, it's strange to 
connector/UDF developer the underlying data value is in millisecond but the 
DataType precision is 0, that's why I want to fix the wrong behavior.

I think the configurable precision is right thing and we should improve it in 
the future.

> Failed to define watermark on computed column of CURRENT_TIMESTAMP and 
> LOCALTIMESTAMP
> -------------------------------------------------------------------------------------
>
>                 Key: FLINK-22354
>                 URL: https://issues.apache.org/jira/browse/FLINK-22354
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / API
>            Reporter: Jark Wu
>            Assignee: Leonard Xu
>            Priority: Blocker
>             Fix For: 1.13.0, 1.14.0
>
>
> It is very common to define watermarks on {{localtimestamp}} and 
> {{current_tiemstamp}} to support *ingestion time*.  However, the following 
> DDLs failed in v1.13. I also tested the following DDLs can pass in v1.12.1, 
> so this is a regression. 
> The root cause may be introduced by FLINK-21435 which adds a [strict check to 
> only allow  precision = 
> 3|https://github.com/apache/flink/blob/f51168041512b0473decabb2088c1ff4fa4f34bc/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/DefaultSchemaResolver.java#L225]
>  (precision = 0 should also can be time attribute), however the precision of 
> return type of {{current_timestamp}} and {{localtimestamp}} are 0 (another 
> long-lived bug). We should fix them both. 
> {code:sql}
> Flink SQL> create table datagen_source (
> >     order_number BIGINT,
> >     price        int,
> >     buyer        string,
> >     ts as current_timestamp,
> >     proctime as proctime(),
> >     watermark for ts as ts - interval '0.001' second
> > ) with (
> >     'connector' = 'datagen',
> >     'rows-per-second' = '1'
> > );
> [ERROR] Could not execute SQL statement. Reason:
> org.apache.flink.table.api.ValidationException: Invalid data type of time 
> field for watermark definition. The field must be of type TIMESTAMP(3) or 
> TIMESTAMP_LTZ(3).
> Flink SQL> create table datagen_source (
> >     order_number BIGINT,
> >     price        int,
> >     buyer        string,
> >     ts as cast(current_timestamp as timestamp_ltz(3)),
> >     proctime as proctime(),
> >     watermark for ts as ts - interval '0.001' second
> > ) with (
> >     'connector' = 'datagen',
> >     'rows-per-second' = '1'
> > );
> [INFO] Execute statement succeed.
> Flink SQL> create table datagen_source2 (
> >     order_number BIGINT,
> >     price        int,
> >     buyer        string,
> >     ts as localtimestamp,
> >     proctime as proctime(),
> >     watermark for ts as ts - interval '0.001' second
> > ) with (
> >     'connector' = 'datagen',
> >     'rows-per-second' = '1'
> > );
> [ERROR] Could not execute SQL statement. Reason:
> org.apache.flink.table.api.ValidationException: Invalid data type of time 
> field for watermark definition. The field must be of type TIMESTAMP(3) or 
> TIMESTAMP_LTZ(3).
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to