[ 
https://issues.apache.org/jira/browse/CALCITE-6345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17832347#comment-17832347
 ] 

Mihai Budiu commented on CALCITE-6345:
--------------------------------------

I see a test in IntervalTest.subTestIntervalYearNegative() that seems to imply 
that this behavior is by design:

{code:java}
    f.wholeExpr("INTERVAL '100' YEAR")
        .fails("Interval field value 100 exceeds precision of YEAR\\(2\\) 
field.*");
{code}

However, at least in Postgres this expression is legal. Why is this test 
expected to fail?

> Intervals with more than 100 years are not supported
> ----------------------------------------------------
>
>                 Key: CALCITE-6345
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6345
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.36.0
>            Reporter: Mihai Budiu
>            Priority: Minor
>
> Adding the following SqlValidatorTest:
> {code:java}
>     expr("INTERVAL '100-2' YEAR TO MONTH").assertInterval(is(122L));
> {code}
> causes the following exception:
> {code}
> 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)
> {code}
> The spec does not limit years to 2 digits, so I don't know where the YEAR(2) 
> time is coming from.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to