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

Intervals with more than 100 years are not supported

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.36.0
    • 1.37.0
    • core

    Description

      Adding the following SqlValidatorTest:

          expr("INTERVAL '100-2' YEAR TO MONTH").assertInterval(is(122L));
      

      causes the following exception:

      org.apache.calcite.runtime.CalciteContextException: From line 1, column 9 to line 1, column 38: Interval field value 100 exceeds precision of YEAR(2) field
      	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
      	at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:507)
      	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:948)
      	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:933)
      	at org.apache.calcite.sql.SqlIntervalQualifier.fieldExceedsPrecisionException(SqlIntervalQualifier.java:1355)
      	at org.apache.calcite.sql.SqlIntervalQualifier.checkLeadFieldInRange(SqlIntervalQualifier.java:475)
      	at org.apache.calcite.sql.SqlIntervalQualifier.evaluateIntervalLiteralAsYearToMonth(SqlIntervalQualifier.java:626)
      	at org.apache.calcite.sql.SqlIntervalQualifier.evaluateIntervalLiteral(SqlIntervalQualifier.java:1293)
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateLiteral(SqlValidatorImpl.java:3429)
      

      The spec does not limit years to 2 digits, so I don't know where the YEAR(2) time is coming from.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mbudiu Mihai Budiu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: