SabrinaZhaozyf commented on code in PR #9296:
URL: https://github.com/apache/pinot/pull/9296#discussion_r959020964


##########
pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/CastTransformFunctionTest.java:
##########
@@ -30,6 +33,70 @@
 
 public class CastTransformFunctionTest extends BaseTransformFunctionTest {
 
+  @Test
+  public void testCastTransformFunctionMV() {
+    ExpressionContext expression =
+        RequestContextUtils.getExpression(String.format("CAST(%s AS LONG)", 
STRING_LONG_MV_COLUMN));
+    TransformFunction transformFunction = 
TransformFunctionFactory.get(expression, _dataSourceMap);
+    Assert.assertTrue(transformFunction instanceof CastTransformFunction);
+    assertEquals(transformFunction.getName(), 
CastTransformFunction.FUNCTION_NAME);
+    long[][] expectedLongValues = new long[NUM_ROWS][];
+    ArrayCopyUtils.copy(_stringLongFormatMVValues, expectedLongValues, 
NUM_ROWS);
+    testCastTransformFunctionMV(transformFunction, expectedLongValues);
+
+    expression = RequestContextUtils.getExpression(
+        String.format("CAST(CAST(CAST(%s AS LONG) as DOUBLE) as INT)", 
STRING_LONG_MV_COLUMN));
+    transformFunction = TransformFunctionFactory.get(expression, 
_dataSourceMap);
+    Assert.assertTrue(transformFunction instanceof CastTransformFunction);
+    assertEquals(transformFunction.getName(), 
CastTransformFunction.FUNCTION_NAME);
+    long[][] innerLongValues = new long[NUM_ROWS][];
+    ArrayCopyUtils.copy(_stringLongFormatMVValues, innerLongValues, NUM_ROWS);
+    double[][] innerDoubleValues = new double[NUM_ROWS][];
+    ArrayCopyUtils.copy(innerLongValues, innerDoubleValues, NUM_ROWS);
+    int[][] expectedIntValues = new int[NUM_ROWS][];
+    ArrayCopyUtils.copy(innerDoubleValues, expectedIntValues, NUM_ROWS);
+    testCastTransformFunctionMV(transformFunction, expectedIntValues);
+
+    expression =
+        RequestContextUtils.getExpression(String.format("CAST(CAST(%s AS INT) 
as FLOAT)", FLOAT_MV_COLUMN));
+    transformFunction = TransformFunctionFactory.get(expression, 
_dataSourceMap);
+    Assert.assertTrue(transformFunction instanceof CastTransformFunction);
+    assertEquals(transformFunction.getName(), 
CastTransformFunction.FUNCTION_NAME);
+    int[][] innerLayerInt = new int[NUM_ROWS][];
+    ArrayCopyUtils.copy(_floatMVValues, innerLayerInt, NUM_ROWS);
+    float[][] expectedFloatValues = new float[NUM_ROWS][];
+    ArrayCopyUtils.copy(innerLayerInt, expectedFloatValues, NUM_ROWS);
+    testCastTransformFunctionMV(transformFunction, expectedFloatValues);
+
+    expression = RequestContextUtils.getExpression(
+        String.format("CAST(CAST(CAST(%s AS FLOAT) as INT) as STRING)", 
INT_MV_COLUMN));
+    transformFunction = TransformFunctionFactory.get(expression, 
_dataSourceMap);
+    Assert.assertTrue(transformFunction instanceof CastTransformFunction);
+    assertEquals(transformFunction.getName(), 
CastTransformFunction.FUNCTION_NAME);
+    float[][] innerFloatValues = new float[NUM_ROWS][];
+    ArrayCopyUtils.copy(_intMVValues, innerFloatValues, NUM_ROWS);
+    innerLayerInt = new int[NUM_ROWS][];
+    ArrayCopyUtils.copy(innerFloatValues, innerLayerInt, NUM_ROWS);
+    String[][] expectedStringValues = new String[NUM_ROWS][];
+    ArrayCopyUtils.copy(innerLayerInt, expectedStringValues, NUM_ROWS);
+    testCastTransformFunctionMV(transformFunction, expectedStringValues);
+
+    expression = 
RequestContextUtils.getExpression(String.format("arrayMax(cAst(%s AS INT))", 
DOUBLE_MV_COLUMN));
+    transformFunction = TransformFunctionFactory.get(expression, 
_dataSourceMap);
+    FieldSpec.DataType resultDataType = 
transformFunction.getResultMetadata().getDataType();
+    Assert.assertEquals(resultDataType, FieldSpec.DataType.INT);
+
+    expression = 
RequestContextUtils.getExpression(String.format("arraySum(cAst(%s AS INT))", 
DOUBLE_MV_COLUMN));

Review Comment:
   Done



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to