You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/12/08 23:51:51 UTC

[GitHub] [druid] jihoonson commented on a change in pull request #11923: Fix incorrect type conversion in DruidLogicalValueRule

jihoonson commented on a change in pull request #11923:
URL: https://github.com/apache/druid/pull/11923#discussion_r765326343



##########
File path: sql/src/main/java/org/apache/druid/sql/calcite/rule/DruidLogicalValuesRule.java
##########
@@ -110,6 +111,13 @@ static Object getValueFromLiteral(RexLiteral literal, PlannerContext plannerCont
       case SMALLINT:
       case INTEGER:
       case BIGINT:
+        // Safegaurd in case the internal implementaion of the RexLiteral for numbers change
+        Object maybeBigDecimalImpl = literal.getValue();
+        if (maybeBigDecimalImpl instanceof BigDecimal) {
+          return ((BigDecimal) maybeBigDecimalImpl).longValue();
+        }
+        // This might return incorrect value if the literal was created from float.
+        // For example, representation of the form 123.0 can return 1230

Review comment:
       BTW, I was not sure if this is a bug or not, so posted a question in the calcite dev (https://lists.apache.org/thread/yr26vot133q9p7kjjh8nlq6pb1mjx9vl).




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

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



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