amrishlal commented on a change in pull request #6403:
URL: https://github.com/apache/incubator-pinot/pull/6403#discussion_r556936513



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/query/pruner/ColumnValueSegmentPruner.java
##########
@@ -239,17 +240,24 @@ private boolean pruneRangePredicate(IndexSegment segment, 
RangePredicate rangePr
     return false;
   }
 
+  /**
+   * Convert String value to specified numerical type. We first verify that 
the input string contains a number by parsing
+   * it as BigDecimal. The resulting BigDecimal is then downcast to specified 
numerical type. This allows us to create predicates
+   * which allow for comparing values of two different numerical types such as:
+   * SELECT * FROM table WHERE a > 5.0
+   * SELECT * FROM table WHERE timestamp > NOW() - 5.0.
+   */
   private static Comparable convertValue(String stringValue, DataType 
dataType) {
     try {
       switch (dataType) {
         case INT:
-          return Integer.valueOf(stringValue);
+          return (new BigDecimal(stringValue)).intValue();

Review comment:
       The problem is that currently `stringValue` could be anything (Integer, 
Float, Double, Long, Text), so we need: 1) a way to tell if stringValue 
represents a number (and for this `stringValue` is parsed as a BigDecimal which 
parses a wide variety of numerical formats), and 2) if `stringValue` is a 
number then we need to upcast/downcast that number to same value as the column 
type for binary search.




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

Reply via email to