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



##########
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:
       I highly suspect this will have potential impact on performance 
(especially for high throughput cases). I think the original case that you were 
trying to address was a case where Pinot returned a specific data type `double` 
as part of a UDF that was being compared to a column with data type `long`. 
Also, from what I recall, the question was whether the UDF itself should have 
returned long.
   In the example you mentioned, the RHS is provided by the user, and not 
really the output of UDF.
   
   My recommendation is to first find out how other SQL engines behave in such 
cases, as in:
   - Do they throw error for incompatible comparison?
   - Downcast RHS before comparison
   - Upcast LHS before comparison
   - Some other behavior




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