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

Interval type specifier with zero fractional second precision does not pass validation

    XMLWordPrintableJSON

Details

    Description

      Consider interval expression 

      interval '1' second(1, 0) 

      Calcite SQL validator considers it as not correct, since it uses following lower bound for fractional seconds precision:

      public static final int MIN_INTERVAL_FRACTIONAL_SECOND_PRECISION = 1;

      In order to reproduce this issue one can add following test cast to SqlValidatorTest.java:

      @Test void testSecondIntervalExpression() {
        expr("interval '1' second(1, 0)").columnType("INTERVAL SECOND(1, 0) NOT NULL");
      } 

      and get an error:

      Interval fractional second precision '0' out of range for INTERVAL SECOND(1, 0) 

      However, SQL standard say:

      An <interval fractional seconds precision>, if specified, shall be greater than or equal to 0 (zero)
      and shall not be greater than the implementation-defined maximum. If SECOND is specified
      and <interval fractional seconds precision> is not specified, then an <interval fractional seconds
      precision> of 6 is implicit. 

      Consequently, MIN_INTERVAL_FRACTIONAL_SECOND_PRECISION should be equal to 0 to make Calcite behavior consistent with SQL specification.

      Attachments

        Issue Links

          Activity

            People

              lchistov1987 Leonid Chistov
              lchistov1987 Leonid Chistov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: