manner commented on code in PR #29080:
URL: https://github.com/apache/flink/pull/29080#discussion_r3925626633


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/VariantCastUtils.java:
##########
@@ -180,12 +189,14 @@ private static String decimalTarget(int precision, int 
scale) {
     }
 
     /**
-     * Reads a timestamp variant as the target {@code TIMESTAMP}. A variant 
keeps microseconds, so
-     * 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}. {@link 
Variant#getDateTime()}
+     * already 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.
      */
     public static TimestampData toTimestamp(Variant variant, int precision) {
-        if (variant.getType() != Variant.Type.TIMESTAMP) {
+        final Variant.Type type = variant.getType();
+        if (type != Variant.Type.TIMESTAMP && type != 
Variant.Type.TIMESTAMP_NS) {
             throw unsupportedKind(variant, String.format("TIMESTAMP(%d)", 
precision));
         }
         return DateTimeUtils.truncate(

Review Comment:
   Thanks for catching this @mateczagany! I'll add a fix in this PR! 



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