xtern commented on code in PR #3558:
URL: https://github.com/apache/ignite-3/pull/3558#discussion_r1557420442
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/IgniteSqlFunctions.java:
##########
@@ -574,6 +575,75 @@ public static Long subtractTimeZoneOffset(long timestamp,
TimeZone timeZone) {
return timestamp - offset;
}
+ /**
+ * Helper for CAST({timestamp} AS VARCHAR(n)).
+ *
+ * <p>Note: this method is a copy of the avatica {@link
DateTimeUtils#unixTimestampToString(long, int)} method,
+ * with the only difference being that it does not add trailing
zeros.
+ */
+ public static String unixTimestampToString(long timestamp, int precision) {
Review Comment:
> is it critical that we append trailing zeros ?
Without removing trailing zeros current conversion
from TIMESTAMP to TIMESTAMP TZ fails in `TimestampString#normalize` method.
For example for string `2008-01-01 00:00:01.000000`
It removes all zeros and got `2008-01-01 00:00:01.` and then expects that
after '.' will be at least one digit.
I don't think this is critical since we can implement our own TIMESTAMP to
TIMESTAMP_TZ conversion.
> it made for consistency between different temporal tests conversion
From my point of view, yes, it makes the current behavior more consistent.
The following queries:
```
SELECT (TIMESTAMP '2008-01-01 00:00:01.001')::VARCHAR
SELECT '2008-01-01 00:00:01.001'::TIMESTAMP::VARCHAR
SELECT '2008-01-01 00:00:01.001'::TIMESTAMP WITH LOCAL TIME ZONE::VARCHAR
SELECT (TIMESTAMP WITH LOCAL TIME ZONE '2008-01-01 00:00:01.001')::VARCHAR
```
Output the following result before this change:
```
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001000
2008-01-01 00:00:01.001 UTC
2008-01-01 00:00:01.001 UTC
```
After this change:
```
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001
2008-01-01 00:00:01.001 UTC
2008-01-01 00:00:01.001 UTC
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]