Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-15418

Calcite engine. TIMESTAMPDIFF function returns INTEGER type for MICROSECOND time unit

    XMLWordPrintableJSON

Details

    • Docs Required, Release Notes Required

    Description

      SQL function TIMESTAMPDIFF returns INTEGER type for MICROSECOND time unit, but sometimes precession of int is not enough to store value. For example, value for

      SELECT TIMESTAMPDIFF(MICROSECOND, TIMESTAMP '2022-02-01 10:30:26.000', TIMESTAMP '2022-05-01 10:30:28.122')

      is 7689602122000, and it's more then maximum int value. It's better to extend TIMESTAMPDIFF return type to BIGINT for MICROSECOND time unit (SqlTimestampDiffFunction.RETURN_TYPE_INFERENCE should be changed). 

      The main problem - this function is defined in Calcite and hardcoded in the parser (see TimestampDiffFunctionCall in Parser.jj), so it's not so easy to provide our own implementation.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              alex_pl Aleksey Plekhanov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: