xiangfu0 commented on a change in pull request #7332: URL: https://github.com/apache/pinot/pull/7332#discussion_r692616921
########## 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")) { + return DataType.BOOLEAN; + } + + // Try to interpret the literal as TIMESTAMP + try { + Timestamp.valueOf(literal); + return DataType.TIMESTAMP; Review comment: I saw a test with TIMESTAMP, just curious is it possible to CAST a TIMESTAMP value to STRING, then do the comparison? -- 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