xiangfu0 commented on code in PR #19165:
URL: https://github.com/apache/pinot/pull/19165#discussion_r3723298157
##########
pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/CastTransformFunctionTest.java:
##########
@@ -35,6 +35,17 @@
public class CastTransformFunctionTest extends BaseTransformFunctionTest {
+ @Test
+ public void testCastUuidToString() {
+ String uuid = "550e8400-e29b-41d4-a716-446655440000";
+ ExpressionContext expression =
RequestContextUtils.getExpression("CAST(toUuid('" + uuid + "') AS STRING)");
+ TransformFunction transformFunction =
TransformFunctionFactory.get(expression, _dataSourceMap);
+
+ String[] expectedValues = new String[NUM_ROWS];
+ Arrays.fill(expectedValues, uuid);
+ testTransformFunction(transformFunction, expectedValues);
+ }
Review Comment:
Addressed in a60393d6f7: added testCastUuidMvToString, which exercises two
UUID values per row and verifies canonical dashed strings.
##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CastTransformFunction.java:
##########
@@ -423,6 +433,19 @@ public String[][] transformToStringValuesMV(ValueBlock
valueBlock) {
long[][] longValuesMV =
_transformFunction.transformToLongValuesMV(valueBlock);
ArrayCopyUtils.copyFromTimestamp(longValuesMV, _stringValuesMV,
length);
return _stringValuesMV;
+ case UUID:
+ length = valueBlock.getNumDocs();
+ initStringValuesMV(length);
+ byte[][][] uuidValuesMV =
_transformFunction.transformToBytesValuesMV(valueBlock);
+ for (int i = 0; i < length; i++) {
+ int numValues = uuidValuesMV[i].length;
+ String[] stringValues = new String[numValues];
+ for (int j = 0; j < numValues; j++) {
+ stringValues[j] = UuidUtils.toString(uuidValuesMV[i][j]);
+ }
+ _stringValuesMV[i] = stringValues;
+ }
+ return _stringValuesMV;
Review Comment:
Addressed in a60393d6f7: the new MV test calls the UUID
transformToStringValuesMV path with multiple UUIDs in every row.
##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CastTransformFunction.java:
##########
@@ -423,6 +433,19 @@ public String[][] transformToStringValuesMV(ValueBlock
valueBlock) {
long[][] longValuesMV =
_transformFunction.transformToLongValuesMV(valueBlock);
ArrayCopyUtils.copyFromTimestamp(longValuesMV, _stringValuesMV,
length);
return _stringValuesMV;
+ case UUID:
+ length = valueBlock.getNumDocs();
+ initStringValuesMV(length);
+ byte[][][] uuidValuesMV =
_transformFunction.transformToBytesValuesMV(valueBlock);
+ for (int i = 0; i < length; i++) {
+ int numValues = uuidValuesMV[i].length;
+ String[] stringValues = new String[numValues];
+ for (int j = 0; j < numValues; j++) {
+ stringValues[j] = UuidUtils.toString(uuidValuesMV[i][j]);
+ }
+ _stringValuesMV[i] = stringValues;
+ }
+ return _stringValuesMV;
Review Comment:
Addressed in aa13d1fa07: wrapped the MV UUID case in braces to match the SV
case.
--
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]