Jackie-Jiang commented on a change in pull request #6941: URL: https://github.com/apache/incubator-pinot/pull/6941#discussion_r634938732
########## File path: pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CastTransformFunction.java ########## @@ -94,51 +94,157 @@ public TransformResultMetadata getResultMetadata() { @Override public int[] transformToIntValuesSV(ProjectionBlock projectionBlock) { - return _transformFunction.transformToIntValuesSV(projectionBlock); + // When casting to FLOAT, need to first read as the result type then convert to int values + DataType resultStoredType = _resultMetadata.getDataType().getStoredType(); + if (resultStoredType != DataType.FLOAT) { + return _transformFunction.transformToIntValuesSV(projectionBlock); + } else { + if (_intValuesSV == null) { + _intValuesSV = new int[DocIdSetPlanNode.MAX_DOC_PER_CALL]; + } + int numDocs = projectionBlock.getNumDocs(); + float[] floatValues = _transformFunction.transformToFloatValuesSV(projectionBlock); + ArrayCopyUtils.copy(floatValues, _intValuesSV, numDocs); + return _intValuesSV; + } } @Override public long[] transformToLongValuesSV(ProjectionBlock projectionBlock) { - return _transformFunction.transformToLongValuesSV(projectionBlock); + // When casting to INT/FLOAT/DOUBLE, need to first read as the result type then convert to long values + DataType resultStoredType = _resultMetadata.getDataType().getStoredType(); + if (resultStoredType != DataType.INT && resultStoredType != DataType.FLOAT && resultStoredType != DataType.DOUBLE) { + return _transformFunction.transformToLongValuesSV(projectionBlock); + } else { + if (_longValuesSV == null) { + _longValuesSV = new long[DocIdSetPlanNode.MAX_DOC_PER_CALL]; + } + int numDocs = projectionBlock.getNumDocs(); + if (resultStoredType == DataType.INT) { + int[] intValues = _transformFunction.transformToIntValuesSV(projectionBlock); + ArrayCopyUtils.copy(intValues, _longValuesSV, numDocs); + } else if (resultStoredType == DataType.FLOAT) { + float[] floatValues = _transformFunction.transformToFloatValuesSV(projectionBlock); + ArrayCopyUtils.copy(floatValues, _longValuesSV, numDocs); + } else { + double[] doubleValues = _transformFunction.transformToDoubleValuesSV(projectionBlock); + ArrayCopyUtils.copy(doubleValues, _longValuesSV, numDocs); + } + return _longValuesSV; + } } @Override public float[] transformToFloatValuesSV(ProjectionBlock projectionBlock) { - return _transformFunction.transformToFloatValuesSV(projectionBlock); + // When casting to INT/LONG, need to first read as the result type then convert to float values + DataType resultStoredType = _resultMetadata.getDataType().getStoredType(); + if (resultStoredType != DataType.INT && resultStoredType != DataType.LONG) { + return _transformFunction.transformToFloatValuesSV(projectionBlock); + } else { + if (_floatValuesSV == null) { + _floatValuesSV = new float[DocIdSetPlanNode.MAX_DOC_PER_CALL]; + } + int numDocs = projectionBlock.getNumDocs(); + if (resultStoredType == DataType.INT) { Review comment: That is in the `else` block -- 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. 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