[ https://issues.apache.org/jira/browse/IGNITE-21557?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pavel Pereslegin updated IGNITE-21557: -------------------------------------- Description: 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 {code:java} switch (rex.getType().getSqlTypeName()) { case DATE: case TIME: case TIMESTAMP: // *_WITH_LOCAL_TIME_ZONE types missed {code} and 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} TBD: Calcite issue was: 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 {code:java} switch (rex.getType().getSqlTypeName()) { case DATE: case TIME: case TIMESTAMP: // *_WITH_LOCAL_TIME_ZONE types missed {code} and 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} TBD: Calcite issue Also the following case should be investigated {code:java} ... static { TimeZone.setDefault(TimeZone.getTimeZone("Europe/Volgograd")); } ... assertQuery("SELECT timestamp with local time zone '1992-09-26 02:30:00' + interval (25) hours") .returns(sqlTimestamp("1992-09-27T03:30:00.000")).check(); // Expected: 1992-09-27T00:30:00Z <class java.time.Instant> // Actual: 1992-09-26T23:30:00Z <class java.time.Instant> {code} > 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 > {code:java} > switch (rex.getType().getSqlTypeName()) { > case DATE: > case TIME: > case TIMESTAMP: > // *_WITH_LOCAL_TIME_ZONE types missed > {code} > and 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} > TBD: Calcite issue -- This message was sent by Atlassian Jira (v8.20.10#820010)