Jackie-Jiang commented on code in PR #19181:
URL: https://github.com/apache/pinot/pull/19181#discussion_r3737824202
##########
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:
(minor) Put UUID_ARRAY below, after all array types
Not introduced in this PR, but should we add BYTES_ARRAY as well?
##########
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:
(nit) Split into 2 statement same as others. It is more explicit the
original stored value is BYTES. Same for the other place
##########
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:
This method should be moved below
--
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]