Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-22354

Failed to define watermark on computed column of CURRENT_TIMESTAMP and LOCALTIMESTAMP

    XMLWordPrintableJSON

Details

    Description

      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 (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.

      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).
      

      Attachments

        Issue Links

          Activity

            People

              leonard Leonard Xu
              jark Jark Wu
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: