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

yanjing.wang commented on CALCITE-5024:
---------------------------------------

Hi [~julianhyde] , Do you mean I need assign an enough precision when parsing 
interval expression?

 

I found the interval precision is dialect-specific, for example, 
{code:java}
select interval '100' year  {code}
Oracle throws 'ORA-01873: the leading precision of the interval is too small', 
but BigQuery, PostgreSQL passes.

 

 

> Big INTERVAL_HOUR precision can't be converted to row expression
> ----------------------------------------------------------------
>
>                 Key: CALCITE-5024
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5024
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.29.0
>         Environment: jdk8
>            Reporter: yanjing.wang
>            Assignee: yanjing.wang
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> {code:java}
> @Test void testBigIntervalHourPrecision() {
>   String expr = "interval '1000000' hour";
>   expr(expr).withFactory(t -> t.withTypeFactoryFactory(
>       f -> new JavaTypeFactoryImpl() {
>         @Override
>         public RelDataTypeSystem getTypeSystem() {
>           return new RelDataTypeSystemImpl() {
>             @Override
>             public int getDefaultPrecision(SqlTypeName typeName) {
>               switch (typeName) {
>               case INTERVAL_HOUR:
>                 return SqlTypeName.MAX_INTERVAL_START_PRECISION;
>               default:
>                 break;
>               }
>               return super.getDefaultPrecision(typeName);
>             }
>           };
>         }
>       }
>   )).ok();
> } {code}
> This will cause SqlValidatorException: Interval field value 1,000,000 exceeds 
> precision of HOUR(2) field.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to