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 2021/01/13 22:54:13 UTC

[GitHub] [incubator-pinot] amrishlal commented on a change in pull request #6403: Fix upcasting/downcasting of numerical values used in SQL predicates.

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



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/segment/index/readers/FloatDictionary.java
##########
@@ -30,7 +31,24 @@ public FloatDictionary(PinotDataBuffer dataBuffer, int length) {
 
   @Override
   public int insertionIndexOf(String stringValue) {
-    return binarySearch(Float.parseFloat(stringValue));
+    // First convert string to BigDecimal and then downcast to int. This allows type conversion from any compatible
+    // numerical value represented as string to an int value.
+    BigDecimal bigDecimal = new BigDecimal(stringValue);

Review comment:
       This doesn't appear to be the case. For example if the query is:
       `SELECT count(*) from mytable WHERE intColumn < 3000000000.453`
   then `stringValue` gets set to 3000000000.453 and the current code would throw exception because 3000000000.453 is not a valid integer.
   
   After the change, the above query will evaluate successfully (which is expected SQL behavior). Same with other queries such as:
       `SELECT count(*) from mytable WHERE intColumn = 5.0




----------------------------------------------------------------
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:
users@infra.apache.org



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