siddharthteotia commented on code in PR #9296:
URL: https://github.com/apache/pinot/pull/9296#discussion_r960973394
##########
pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/CastTransformFunctionTest.java:
##########
@@ -30,6 +33,71 @@
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(
Review Comment:
Thanks for adding the nested cast transform tests.
Can you please also add another nested cast transform where the outer
transform is not a `CAST` but some other transform ?
For example, for the internal use case we want to use it inside
`ID_SET(CAST(mv_string_col AS LONG))`. So, a similar test would be great.
--
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]