Jackie-Jiang commented on a change in pull request #7332:
URL: https://github.com/apache/pinot/pull/7332#discussion_r693220587



##########
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:
       I intentionally use `equals()` here because it will always be lower case 
if it is converted from the boolean literal (`true` or `false` without quote). 
Will add some comments here




-- 
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

Reply via email to