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

NPE when using GREATEST() in Flink SQL

    XMLWordPrintableJSON

Details

    Description

      Hi,

      I see NPEs in flink 1.14 and flink 1.16 when running queries with GREATEST() and timestamps. Below is an example to help in reproducing the issue.

      CREATE TEMPORARY VIEW Positions AS
      SELECT
      SecurityId,
      ccy1,
      CAST(publishTimestamp AS TIMESTAMP(3)) as publishTimestamp
      FROM (VALUES
      (1, 'USD', '2022-01-01'),
      (2, 'GBP', '2022-02-02'),
      (3, 'GBX', '2022-03-03'),
      (4, 'GBX', '2022-04-4'))
      AS ccy(SecurityId, ccy1, publishTimestamp);
      
      CREATE TEMPORARY VIEW Benchmarks AS
      SELECT
      SecurityId,
      ccy1,
      CAST(publishTimestamp AS TIMESTAMP(3)) as publishTimestamp
      FROM (VALUES
      (3, 'USD', '2023-01-01'),
      (4, 'GBP', '2023-02-02'),
      (5, 'GBX', '2023-03-03'),
      (6, 'GBX', '2023-04-4'))
      AS ccy(SecurityId, ccy1, publishTimestamp);
      
      SELECT *,
      GREATEST(
      IFNULL(Positions.publishTimestamp,CAST('1970-1-1' AS TIMESTAMP(3))),
      IFNULL(Benchmarks.publishTimestamp,CAST('1970-1-1' AS TIMESTAMP(3)))
      )
      FROM Positions
      FULL JOIN Benchmarks ON Positions.SecurityId = Benchmarks.SecurityId 

       

      Using "IF" is a workaround at the moment instead of using "GREATEST"

        

      Attachments

        Issue Links

          Activity

            People

              Sergey Nuyanzin Sergey Nuyanzin
              hectorrios Hector Rios
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: