Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4698

Respect input types and precision for datetime '+' operator and TIMESTAMPADD function

    XMLWordPrintableJSON

Details

    Description

      Currently SqlTimestampAddFunction#deduceType does not deal with timestamp_ltz type correctly. Return type of timestampadd(..., ..., timestamp_ltz) will be timestamp but it should be timestamp_ltz.
      Same issue is for precision datetime_plus.
      Also precision is lost.

      A number of queries highlighting the issue

      SELECT timestamp '2003-08-02 12:54:01' - INTERVAL '1.123' SECOND(1, 3);
      SELECT time '12:12:12' + INTERVAL '3.456' SECOND(1, 3);
      SELECT timestampadd(SQL_TSI_FRAC_SECOND, 2, timestamp with local time zone '2016-02-24 12:42:25.000');
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              TsReaper Caizhi Weng
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 50m
                  1h 50m