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


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/UuidCastUtils.java:
##########
@@ -46,6 +47,18 @@ public static String toStringValue(byte[] uuidBytes) {
         return new UUID(buffer.getLong(), buffer.getLong()).toString();
     }
 
+    /**
+     * Encodes a {@code UUID} into the canonical 16-byte big-endian 
representation used to store a
+     * {@code UUID} value.
+     */
+    public static byte[] toUuidBytes(UUID uuid) {

Review Comment:
   I think this piece of code exists in many places for UUID now. Could you 
double check if we can re-use this method more and replace the duplicates?



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/casting/CastRulesTest.java:
##########
@@ -2034,6 +2040,13 @@ Stream<CastTestSpecBuilder> testCases() {
                         // them, which is what makes this the way to inspect 
such a value
                         .fromCase(VARIANT(), VARIANT_BUILDER.of(INVALID_UTF8), 
INVALID_UTF8)
                         .fail(VARIANT(), VARIANT_BUILDER.of("foo"), 
TableRuntimeException.class),
+                CastTestSpecBuilder.testCastTo(UUID())
+                        .fromCase(VARIANT(), null, null)
+                        .fromCase(
+                                VARIANT(),
+                                
Variant.newBuilder().of(UUID.fromString(UUID_STRING)),

Review Comment:
   Nit: extract UUID.fromString as static field and re-use



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