raminqaf commented on code in PR #29690:
URL: https://github.com/apache/flink/pull/29690#discussion_r4453547394


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/data/utils/VariantCastUtils.java:
##########
@@ -240,42 +256,107 @@ private static String decimalTarget(int precision, int 
scale) {
     }
 
     /**
-     * Reads a timestamp variant as the target {@code TIMESTAMP}. {@link 
Variant#getDateTime()}
-     * accepts both the microsecond ({@link Variant.Type#TIMESTAMP}) and 
nanosecond ({@link
-     * Variant.Type#TIMESTAMP_NS}) encodings. Fractional seconds beyond the 
target precision are
-     * truncated, the same as a regular {@code TIMESTAMP} to {@code 
TIMESTAMP(p)} cast.
+     * Reads a timestamp variant as the target {@code TIMESTAMP}. A {@code 
TIMESTAMP_LTZ} value is
+     * shifted into the session time zone, the same as a regular {@code 
TIMESTAMP_LTZ} to {@code
+     * TIMESTAMP} cast. Fractional seconds beyond the target precision are 
truncated.
      */
-    public static TimestampData toTimestamp(Variant variant, int precision) {
-        final Variant.Type type = variant.getType();
-        if (type == Variant.Type.TIMESTAMP || type == 
Variant.Type.TIMESTAMP_NS) {
-            return DateTimeUtils.truncate(
-                    TimestampData.fromLocalDateTime(variant.getDateTime()), 
precision);
+    public static TimestampData toTimestamp(Variant variant, int precision, 
ZoneId sessionZone) {
+        final LocalDateTime dateTime = toLocalDateTime(variant, sessionZone);
+        if (dateTime == null) {
+            throw unsupportedKind(variant, String.format("TIMESTAMP(%d)", 
precision));

Review Comment:
   Done



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