xiangfu0 commented on code in PR #19181:
URL: https://github.com/apache/pinot/pull/19181#discussion_r3738441554


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CastTransformFunction.java:
##########
@@ -97,6 +98,14 @@ public void init(List<TransformFunction> arguments, 
Map<String, ColumnContext> c
         case "VARBINARY":
           _resultMetadata = sourceSV ? BYTES_SV_NO_DICTIONARY_METADATA : 
BYTES_MV_NO_DICTIONARY_METADATA;
           break;
+        case "UUID":
+          Preconditions.checkState(sourceSV, "Cannot cast from MV to UUID");
+          _resultMetadata = UUID_SV_NO_DICTIONARY_METADATA;
+          break;
+        case "UUID_ARRAY":

Review Comment:
   Addressed in 
[1ab6eaf2](https://github.com/apache/pinot/pull/19181/commits/1ab6eaf2440784bf43cd2b87db8a724452126f4a):
 moved `UUID_ARRAY` after the other array types, added `BYTES_ARRAY`, and added 
focused coverage for the new target.



##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/ArrayCopyUtils.java:
##########
@@ -286,6 +294,42 @@ public static void copy(String[][] src, byte[][][] dest, 
int length) {
     }
   }
 
+  /// Multi-value variant of [#copyToUuid(String[], byte[][], int)].
+  public static void copyToUuid(String[][] src, byte[][][] dest, int length) {
+    for (int i = 0; i < length; i++) {
+      int rowLength = src[i].length;
+      byte[][] row = new byte[rowLength][];
+      for (int j = 0; j < rowLength; j++) {
+        row[j] = UuidUtils.toBytes(src[i][j]);
+      }
+      dest[i] = row;
+    }
+  }
+
+  /// Multi-value variant of [#copyFromUuid(byte[][], String[], int)].
+  public static void copyFromUuid(byte[][][] src, String[][] dest, int length) 
{

Review Comment:
   Addressed in 
[1ab6eaf2](https://github.com/apache/pinot/pull/19181/commits/1ab6eaf2440784bf43cd2b87db8a724452126f4a):
 moved the MV UUID copy helpers below the corresponding scalar byte helpers.



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CastTransformFunction.java:
##########
@@ -319,13 +328,80 @@ public String[] transformToStringValuesSV(ValueBlock 
valueBlock) {
           byte[][] bytesValues = transformToBytesValuesSV(valueBlock);
           ArrayCopyUtils.copy(bytesValues, _stringValuesSV, length);
           break;
+        // Renders a UUID *result* (e.g. CAST(x AS UUID) read as a string). 
The switch above handles the other
+        // direction, a UUID *source* cast to STRING.
+        case UUID:
+          ArrayCopyUtils.copyFromUuid(transformToBytesValuesSV(valueBlock), 
_stringValuesSV, length);

Review Comment:
   Addressed in 
[1ab6eaf2](https://github.com/apache/pinot/pull/19181/commits/1ab6eaf2440784bf43cd2b87db8a724452126f4a):
 split UUID rendering into fetching the stored `byte[][]` / `byte[][][]` values 
and then calling `copyFromUuid()` in both the SV and MV paths.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to