@Test public void testCastTransformFunction() { ExpressionContext expression = QueryContextConverterUtils.getExpression(String.format("cast(%s,%s)", INT_SV_COLUMN, "'String'")); TransformFunction transformFunction = TransformFunctionFactory.get(expression, _dataSourceMap); Assert.assertTrue(transformFunction instanceof CastTransformFunction); Assert.assertEquals(transformFunction.getName(), CastTransformFunction.FUNCTION_NAME); String[] expectedValues = new String[NUM_ROWS]; for (int i = 0; i < NUM_ROWS; i++) { expectedValues[i] = Integer.toString(_intSVValues[i]); } testTransformFunction(transformFunction, expectedValues); expression = QueryContextConverterUtils.getExpression( String.format("cast(add(cast(%s, 'STRING'), %s), 'string')", STRING_SV_COLUMN, DOUBLE_SV_COLUMN)); transformFunction = TransformFunctionFactory.get(expression, _dataSourceMap); Assert.assertTrue(transformFunction instanceof CastTransformFunction); for (int i = 0; i < NUM_ROWS; i++) { expectedValues[i] = Double.toString(Double.parseDouble(_stringSVValues[i]) + _doubleSVValues[i]); } testTransformFunction(transformFunction, expectedValues); expression = QueryContextConverterUtils.getExpression( String.format("cast(cast(add(cast(%s, 'STRING'), %s), 'string'), 'double')", STRING_SV_COLUMN, INT_SV_COLUMN)); transformFunction = TransformFunctionFactory.get(expression, _dataSourceMap); Assert.assertTrue(transformFunction instanceof CastTransformFunction); double[] expectedDoubleValues = new double[NUM_ROWS]; for (int i = 0; i < NUM_ROWS; i++) { expectedDoubleValues[i] = Double.parseDouble(_stringSVValues[i]) + _intSVValues[i]; } testTransformFunction(transformFunction, expectedDoubleValues); }
@Override public String getName() { return FUNCTION_NAME; }
CastTransformFunction extends BaseTransformFunction { @Override public String getName() { return FUNCTION_NAME; } }
CastTransformFunction extends BaseTransformFunction { @Override public String getName() { return FUNCTION_NAME; }  }
CastTransformFunction extends BaseTransformFunction { @Override public String getName() { return FUNCTION_NAME; }  @Override String getName(); @Override void init(List<TransformFunction> arguments, Map<String, DataSource> dataSourceMap); @Override TransformResultMetadata getResultMetadata(); @Override int[] transformToIntValuesSV(ProjectionBlock projectionBlock); @Override long[] transformToLongValuesSV(ProjectionBlock projectionBlock); @Override float[] transformToFloatValuesSV(ProjectionBlock projectionBlock); @Override double[] transformToDoubleValuesSV(ProjectionBlock projectionBlock); @Override String[] transformToStringValuesSV(ProjectionBlock projectionBlock); }
CastTransformFunction extends BaseTransformFunction { @Override public String getName() { return FUNCTION_NAME; }  @Override String getName(); @Override void init(List<TransformFunction> arguments, Map<String, DataSource> dataSourceMap); @Override TransformResultMetadata getResultMetadata(); @Override int[] transformToIntValuesSV(ProjectionBlock projectionBlock); @Override long[] transformToLongValuesSV(ProjectionBlock projectionBlock); @Override float[] transformToFloatValuesSV(ProjectionBlock projectionBlock); @Override double[] transformToDoubleValuesSV(ProjectionBlock projectionBlock); @Override String[] transformToStringValuesSV(ProjectionBlock projectionBlock); static final String FUNCTION_NAME; }