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

Sql. Fix TIMESTAMP_WITH_LOCAL_TIME_ZONE interval arithmetic.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • sql

    Description

      The following interval arithmetic works incorrectly

      select TIMESTAMP WITH LOCAL TIME ZONE '2021-01-01 00:00:00' + INTERVAL 1 MONTH
      -- result 2021-01-01 00:00:00.001
      select TIMESTAMP WITH LOCAL TIME ZONE '2021-01-01 00:00:00' + INTERVAL 1 YEAR
      -- result 2021-01-01 00:00:00.012
      

      Looks like the main issue is near StandardConvertletTable#convertPlus (selecting wrong execution branch)

          switch (rex.getType().getSqlTypeName()) {
          case DATE:
          case TIME:
          case TIMESTAMP:
      // *_WITH_LOCAL_TIME_ZONE types missed
      

      and probably in DatetimeArithmeticImplementor#implementSafe

              default:
                final BuiltInMethod method =
                    operand0.getType().getSqlTypeName() == SqlTypeName.TIMESTAMP
                        ? BuiltInMethod.ADD_MONTHS
                        : BuiltInMethod.ADD_MONTHS_INT;
                return Expressions.call(method.method, trop0, trop1);
      

      https://issues.apache.org/jira/browse/CALCITE-6287

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              xtern Pavel Pereslegin
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: