You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/09/16 02:51:42 UTC

[GitHub] [pinot] siddharthteotia commented on a diff in pull request #9389: [Feature] [Refactoring] Create LiteralContext to hold type and value of literal and Boolean literal eval support

siddharthteotia commented on code in PR #9389:
URL: https://github.com/apache/pinot/pull/9389#discussion_r972568072


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/LiteralTransformFunction.java:
##########
@@ -58,21 +61,24 @@ public class LiteralTransformFunction implements TransformFunction {
   private String[] _stringResult;
   private byte[][] _bytesResult;
 
-  public LiteralTransformFunction(String literal) {
-    _literal = literal;
-    _dataType = inferLiteralDataType(literal);
-    if (_dataType.isNumeric()) {
-      _bigDecimalLiteral = new BigDecimal(_literal);
-    } else if (_dataType == DataType.BOOLEAN) {
-      _bigDecimalLiteral = PinotDataType.BOOLEAN.toBigDecimal(Boolean.valueOf(literal));
-    } else if (_dataType == DataType.TIMESTAMP) {
-      // inferLiteralDataType successfully interpreted the literal as TIMESTAMP. _bigDecimalLiteral is populated and
-      // assigned to _longLiteral.
-      _bigDecimalLiteral = PinotDataType.TIMESTAMP.toBigDecimal(Timestamp.valueOf(literal));
+  public LiteralTransformFunction(LiteralContext literalContext) {
+    Preconditions.checkNotNull(literalContext);
+    _literal = literalContext.getValue() == null ? "" : literalContext.getValue().toString();
+    if (literalContext.getType() == DataType.BOOLEAN) {
+      _bigDecimalLiteral = PinotDataType.BOOLEAN.toBigDecimal(literalContext.getValue());
+      _dataType = DataType.BOOLEAN;
     } else {
-      _bigDecimalLiteral = BigDecimal.ZERO;
+      _dataType = inferLiteralDataType(_literal);

Review Comment:
   Do we still need to infer the type here given that `LiteralContext` now has the Pinot DataType



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org