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

Pavel Pereslegin edited comment on IGNITE-25174 at 4/29/25 8:29 PM:
--------------------------------------------------------------------

Tests started to fail after this change 
https://github.com/apache/ignite-3/commit/721815f9df9c91e01e3e38428c3e9fe70810b9a1#diff-b55898e9d59f24d67adad5014ee7caf4398d4cdd3385fa1870d7f2f38f9c9445R151

We have the following case:
{code:sql}
(TIME '11:00:00')::TIMESTAMP WITH TIME ZONE
{code}

According to the SQL standard this should be
{noformat}
1. Copy date fields from CURRENT_DATE and time fields from SV
2. Convert resulting TIMESTAMP to TIMESTAMP WITH TIMEZONE
{noformat}

For AI3 it's equal to
{noformat}
1. Copy date fields from CURRENT_TIMESTAMP and time fields from SV
2. Convert resulting TIMESTAMP to TIMESTAMP WITH *LOCAL* TIMEZONE
{noformat}

So, after changing CURRENT_TIMESTAMP from TIMESTAMP (LocalDateTime) to 
TIMESTAMP WITH LOCAL TIME ZONE (Instant) it now returns the number of 
milliseconds in UTC time zone, but before it returned the number of 
milliseconds adjusted to the client time zone.

Let's say we have time 2024-01-01 22:00:00 UTC and we are in UTC+4 time zone, 
if CURRENT_DATE should return 2024-01-02, then we have an issue, because we 
will get the date in UTC (e.g. 2024-01-01).


was (Author: xtern):
Tests started to fail after this change 
https://github.com/apache/ignite-3/commit/721815f9df9c91e01e3e38428c3e9fe70810b9a1#diff-b55898e9d59f24d67adad5014ee7caf4398d4cdd3385fa1870d7f2f38f9c9445R151

We have the following case:
{code:sql}
(TIME '11:00:00')::TIMESTAMP WITH TIME ZONE
{code}

According to the SQL standard this should be
{noformat}
1. Copy date fields from CURRENT_DATE and time fields from SV
2. Convert resulting TIMESTAMP to TIMESTAMP WITH TIMEZONE
{noformat}

For AI3 it's equal to
{noformat}
1. Copy date fields from CURRENT_TIMESTAMP and time fields from SV
2. Convert resulting TIMESTAMP to TIMESTAMP WITH *LOCAL* TIMEZONE
{noformat}

So, after changing CURRENT_TIMESTAMP from TIMESTAMP to TIMESTAMP WITH LOCAL 
TIME ZONE it now returns the number of milliseconds in UTC time zone (and this 
is important because this value if mapped to Instant, and it can hold only UTC 
value), but before it returned the number of milliseconds adjusted to the 
client time zone.

Let's say we have time 2024-01-01 22:00:00 UTC and we are in UTC+4 time zone, 
if CURRENT_DATE should return 2024-01-02 UTC+4, then we have a problem, because 
now in this case we will get the date in UTC (e.g. 2024-01-01).

> Flaky ItCastToTsWithLocalTimeZoneTest
> -------------------------------------
>
>                 Key: IGNITE-25174
>                 URL: https://issues.apache.org/jira/browse/IGNITE-25174
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>            Reporter: Iurii Gerzhedovich
>            Priority: Major
>              Labels: ignite-3
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
>  
>  At least the following tests are flaky:
> {noformat}
> org.apache.ignite.internal.sql.engine.datatypes.ItCastToTsWithLocalTimeZoneTest
>     explicitCastOfDynParamsOnMultiInsert
>     explicitCastOfLiteralsOnMultiInsert
>     explicitCastOfSourceTableOnInsert
>     explicitCastOfSourceTableOnSelect
> org.apache.ignite.internal.sql.engine.datatypes.ItCastToTsWithLocalTimeZoneTest:
>  explicitCastOfDynParamsOnSelect(Object, int, Object): 
> org.apache.ignite.internal.sql.engine.datatypes.ItCastToTsWithLocalTimeZoneTest
>     explicitCastOfDynParamsOnSelect([10] 12:00, 8, 2025-04-17T04:00:00Z)
>     explicitCastOfDynParamsOnSelect([9] 12:00, 4, 2025-04-17T08:00:00Z)
> org.apache.ignite.internal.sql.engine.datatypes.ItCastToTsWithLocalTimeZoneTest:
>  explicitCastOfLiteralsOnInsert(String, int, Object): 
> org.apache.ignite.internal.sql.engine.datatypes.ItCastToTsWithLocalTimeZoneTest:
>     explicitCastOfLiteralsOnInsert([10] time '12:00:00', 8, 
> 2025-04-17T04:00:00Z)
>     explicitCastOfLiteralsOnInsert([9] time '12:00:00', 4, 
> 2025-04-17T08:00:00Z)
> org.apache.ignite.internal.sql.engine.datatypes.ItCastToTsWithLocalTimeZoneTest:
>  explicitCastOfLiteralsOnSelect(String, int, Object): 
> org.apache.ignite.internal.sql.engine.datatypes.ItCastToTsWithLocalTimeZoneTest:
>     explicitCastOfLiteralsOnSelect([10] time '12:00:00', 8, 
> 2025-04-17T04:00:00Z)
>     explicitCastOfLiteralsOnSelect([9] time '12:00:00', 4, 
> 2025-04-17T08:00:00Z)
> org.apache.ignite.internal.sql.engine.datatypes.ItCastToTsWithLocalTimeZoneTest:
>  explicitCastOfDynParamsOnInsert(Object, int, Object): 
> org.apache.ignite.internal.sql.engine.datatypes.ItCastToTsWithLocalTimeZoneTest:
>     explicitCastOfDynParamsOnInsert([10] 12:00, 8, 2025-04-17T04:00:00Z)
>     explicitCastOfDynParamsOnInsert([9] 12:00, 4, 2025-04-17T08:00:00Z)
> {noformat}
>  
> Examples of failure:
> {code:java}
> org.opentest4j.AssertionFailedError: Collections are not equal (position 0):
> Expected: 2025-04-17T04:00:00Z <class java.time.Instant>
> Actual:   2025-04-16T04:00:00Z <class java.time.Instant>
> org.opentest4j.AssertionFailedError: Collections are not equal (position 0):
> Expected: 2025-04-17T04:00:00Z <class java.time.Instant>
> Actual:   2025-04-16T04:00:00Z <class java.time.Instant>
>   at app//org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:38)
>   at app//org.junit.jupiter.api.Assertions.fail(Assertions.java:138)
>   at 
> app//org.apache.ignite.internal.sql.engine.util.QueryChecker.assertEqualsCollections(QueryChecker.java:195)
>   at 
> app//org.apache.ignite.internal.sql.engine.util.QueryChecker.assertEqualsCollections(QueryChecker.java:190)
>   at 
> app//org.apache.ignite.internal.sql.engine.util.QueryCheckerImpl$RowByRowResultChecker.check(QueryCheckerImpl.java:533)
>   at 
> app//org.apache.ignite.internal.sql.engine.util.QueryCheckerImpl.check(QueryCheckerImpl.java:383)
>   at 
> app//org.apache.ignite.internal.sql.engine.util.QueryCheckerFactoryImpl$1.check(QueryCheckerFactoryImpl.java:90)
>   at 
> app//org.apache.ignite.internal.sql.engine.datatypes.ItCastToTsWithLocalTimeZoneTest.explicitCastOfDynParamsOnMultiInsert(ItCastToTsWithLocalTimeZoneTest.java:211)
>   at java.base@17.0.6/java.lang.reflect.Method.invoke(Method.java:568)
>   at java.base@17.0.6/java.util.ArrayList.forEach(ArrayList.java:1511)
>   at java.base@17.0.6/java.util.ArrayList.forEach(ArrayList.java:1511)
> {code}
> {code:java}
> org.opentest4j.AssertionFailedError: Collections are not equal (position 0):
> Expected: 2025-04-17T08:00:00Z <class java.time.Instant>
> Actual:   2025-04-16T08:00:00Z <class java.time.Instant>
> org.opentest4j.AssertionFailedError: Collections are not equal (position 0):
> Expected: 2025-04-17T08:00:00Z <class java.time.Instant>
> Actual:   2025-04-16T08:00:00Z <class java.time.Instant>
>   at app//org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:38)
>   at app//org.junit.jupiter.api.Assertions.fail(Assertions.java:138)
>   at 
> app//org.apache.ignite.internal.sql.engine.util.QueryChecker.assertEqualsCollections(QueryChecker.java:195)
>   at 
> app//org.apache.ignite.internal.sql.engine.util.QueryChecker.assertEqualsCollections(QueryChecker.java:190)
>   at 
> app//org.apache.ignite.internal.sql.engine.util.QueryCheckerImpl$RowByRowResultChecker.check(QueryCheckerImpl.java:533)
>   at 
> app//org.apache.ignite.internal.sql.engine.util.QueryCheckerImpl.check(QueryCheckerImpl.java:383)
>   at 
> app//org.apache.ignite.internal.sql.engine.util.QueryCheckerFactoryImpl$1.check(QueryCheckerFactoryImpl.java:90)
>   at 
> app//org.apache.ignite.internal.sql.engine.datatypes.ItCastToTsWithLocalTimeZoneTest.explicitCastOfDynParamsOnInsert(ItCastToTsWithLocalTimeZoneTest.java:153)
> {code}
>  
>  



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

Reply via email to