twalthr commented on code in PR #27650:
URL: https://github.com/apache/flink/pull/27650#discussion_r2845142000


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/expressions/ValueLiteralExpression.java:
##########
@@ -283,11 +284,14 @@ public String asSerializableString(SqlFactory sqlFactory) 
{
                         
localDateTime.toLocalTime().format(DateTimeFormatter.ISO_LOCAL_TIME));
             case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
                 final Instant instant = getValueAs(Instant.class).get();
-                if (instant.getNano() % 1_000_000 != 0) {
-                    throw new TableException(
-                            "Maximum precision for 
TIMESTAMP_WITH_LOCAL_TIME_ZONE literals is '3'");
-                }
-                return String.format("TO_TIMESTAMP_LTZ(%d, %d)", 
instant.toEpochMilli(), 3);
+                final LocalDateTime localDateTimeWithTimeZone =
+                        instant.atOffset(ZoneOffset.UTC).toLocalDateTime();
+                return String.format(
+                        "TIMESTAMP WITH LOCAL TIME ZONE '%s %s'",

Review Comment:
   Unfortunately, solving this issue is not straight forward. Instant is in 
UTC. But TIMESTAMP_LTZ literals are already in the local time zone, so we would 
need access to the currently set timezone of the session to convert the instant 
to this. A better alternative is to use `TO_TIMESTAMP_LTZ`, I crafted already a 
PR for this but then figured out that TO_TIMESTAMP_LTZ also doesn't support 
precision 9. TLDR: We need to support TO_TIMESTAMP_LTZ with precision 9 first. 
Related to https://issues.apache.org/jira/browse/FLINK-14925. We what we could 
try is to use `CAST(TIMESTAMP 'x' AS TIMESTAMP_LTZ)`.



-- 
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]

Reply via email to