Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-24403 Improve behaviour of CAST
  3. FLINK-24588

Optimisation of chained cast calls can lead to unexpected behaviour

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.15.0
    • None
    • Table SQL / Planner
    • None

    Description

      Simplification of Cast chained calls can lead to unexpected behaviour:
      CAST(CAST(CAST(123456 AS TINYINT) AS INT) AS BIGINT)
      is simplified to 

      CAST(123456 AS BIGINT)

      and returns 123456 with BIGINT data type, where the first inner cast as TINYINT should already fail because the value is out of range.

      For example, for PostgreSQL:

      postgres=# select 123456::smallint::int::bigint;
      ERROR: smallint out of range
      
      

      Corresponding issue has been create at calcite: https://issues.apache.org/jira/browse/CALCITE-4861

      Attachments

        Activity

          People

            Sergey Nuyanzin Sergey Nuyanzin
            matriv Marios Trivyzas
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: