You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "abhishekagarwal87 (via GitHub)" <gi...@apache.org> on 2024/03/04 10:26:59 UTC

Re: [PR] Rows.objectToNumber: Accept decimals with output type LONG. (druid)

abhishekagarwal87 commented on code in PR #15999:
URL: https://github.com/apache/druid/pull/15999#discussion_r1510918837


##########
processing/src/main/java/org/apache/druid/data/input/Rows.java:
##########
@@ -186,6 +174,18 @@ public static Number objectToNumber(
         return (Number) NullHandling.defaultValueForType(outputType != null ? outputType : ValueType.LONG);
       }
     }
+
+    if (outputType == null || asNumber == null) {
+      return asNumber;
+    } else if (outputType == ValueType.LONG) {
+      return asNumber.longValue();
+    } else if (outputType == ValueType.FLOAT) {
+      return asNumber.floatValue();
+    } else if (outputType == ValueType.DOUBLE) {
+      return asNumber.doubleValue();
+    } else {
+      throw new ISE("Cannot read number as type[%s]", outputType);

Review Comment:
   ```suggestion
         throw new ISE("Cannot read number as type[%s] for field [%s]", outputType, name);
   ```



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