xiangfu0 commented on a change in pull request #7332: URL: https://github.com/apache/pinot/pull/7332#discussion_r692613502
########## File path: pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/LiteralTransformFunction.java ########## @@ -47,24 +52,43 @@ public LiteralTransformFunction(String literal) { _literal = literal; + _dataType = inferLiteralDataType(literal); } - public static FieldSpec.DataType inferLiteralDataType(LiteralTransformFunction transformFunction) { - String literal = transformFunction.getLiteral(); + @VisibleForTesting + static DataType inferLiteralDataType(String literal) { + // Try to interpret the literal as number try { - Number literalNum = NumberUtils.createNumber(literal); - if (literalNum instanceof Integer) { - return FieldSpec.DataType.INT; - } else if (literalNum instanceof Long) { - return FieldSpec.DataType.LONG; - } else if (literalNum instanceof Float) { - return FieldSpec.DataType.FLOAT; - } else if (literalNum instanceof Double) { - return FieldSpec.DataType.DOUBLE; + Number number = NumberUtils.createNumber(literal); + if (number instanceof Integer) { + return DataType.INT; + } else if (number instanceof Long) { + return DataType.LONG; + } else if (number instanceof Float) { + return DataType.FLOAT; + } else if (number instanceof Double) { + return DataType.DOUBLE; + } else { + return DataType.STRING; } } catch (Exception e) { + // Ignored + } + + // Try to interpret the literal as BOOLEAN + if (literal.equals("true") || literal.equals("false")) { Review comment: equals ignore cases? ########## File path: pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/LiteralTransformFunction.java ########## @@ -104,7 +128,11 @@ public Dictionary getDictionary() { public int[] transformToIntValuesSV(ProjectionBlock projectionBlock) { if (_intResult == null) { _intResult = new int[DocIdSetPlanNode.MAX_DOC_PER_CALL]; - Arrays.fill(_intResult, Integer.parseInt(_literal)); + if (_dataType != DataType.BOOLEAN) { + Arrays.fill(_intResult, new BigDecimal(_literal).intValue()); + } else { + Arrays.fill(_intResult, _literal.equals("true") ? 1 : 0); Review comment: if we want to support ignore cases -- 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