raminqaf commented on code in PR #27757:
URL: https://github.com/apache/flink/pull/27757#discussion_r2944970654
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/expressions/ValueLiteralExpression.java:
##########
@@ -283,11 +285,10 @@ 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 int precision =
+ ((LocalZonedTimestampType)
dataType.getLogicalType()).getPrecision();
+ long epochValue = DateTimeUtils.toEpochValue(instant,
precision);
+ return String.format("TO_TIMESTAMP_LTZ(%d, %d)", epochValue,
precision);
Review Comment:
Good catch. Changed the logic to use the sting-based date format. Now based
on the precision we pass in the format.
```java
final String formatPattern =
ltzPrecision > 0
? "yyyy-MM-dd HH:mm:ss." +
"S".repeat(ltzPrecision)
: "yyyy-MM-dd HH:mm:ss";
```
--
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]