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

Maksim Zhuravkov commented on IGNITE-21557:
-------------------------------------------

Year boundaries are not taken into account as well

{noformat}
sql-cli> SELECT TIMESTAMP WITH LOCAL TIME ZONE '2000-01-01 16:00:00' + INTERVAL 
'9999' years;
 2000-01-01T14:01:59.988Z 
{noformat}


> Sql. Fix TIMESTAMP_WITH_LOCAL_TIME_ZONE interval arithmetic.
> ------------------------------------------------------------
>
>                 Key: IGNITE-21557
>                 URL: https://issues.apache.org/jira/browse/IGNITE-21557
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>            Reporter: Pavel Pereslegin
>            Priority: Major
>              Labels: ignite-3
>
> The following interval arithmetic works incorrectly
> {code:SQL}
> 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
> {code}
> Looks like the main issue is near StandardConvertletTable#convertPlus 
> (selecting wrong execution branch)
> {code:java}
>     switch (rex.getType().getSqlTypeName()) {
>     case DATE:
>     case TIME:
>     case TIMESTAMP:
> // *_WITH_LOCAL_TIME_ZONE types missed
> {code}
> and probably in DatetimeArithmeticImplementor#implementSafe
> {code:java}
>         default:
>           final BuiltInMethod method =
>               operand0.getType().getSqlTypeName() == SqlTypeName.TIMESTAMP
>                   ? BuiltInMethod.ADD_MONTHS
>                   : BuiltInMethod.ADD_MONTHS_INT;
>           return Expressions.call(method.method, trop0, trop1);
> {code}
> https://issues.apache.org/jira/browse/CALCITE-6287



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

Reply via email to