nishantmonu51 commented on a change in pull request #5958: Part 2 of changes
for SQL Compatible Null Handling
URL: https://github.com/apache/incubator-druid/pull/5958#discussion_r204816952
##########
File path: common/src/main/java/io/druid/math/expr/ExprEval.java
##########
@@ -245,36 +252,63 @@ public final ExprType type()
@Override
public final int asInt()
{
- if (value == null) {
+ Number number = asNumber();
+ if (number == null) {
assert NullHandling.replaceWithDefault();
return 0;
}
-
- final Integer theInt = Ints.tryParse(value);
- assert NullHandling.replaceWithDefault() || theInt != null;
- return theInt == null ? 0 : theInt;
+ return number.intValue();
}
@Override
public final long asLong()
{
- // GuavaUtils.tryParseLong handles nulls, no need for special null
handling here.
- final Long theLong = GuavaUtils.tryParseLong(value);
- assert NullHandling.replaceWithDefault() || theLong != null;
- return theLong == null ? 0L : theLong;
+ Number number = asNumber();
+ if (number == null) {
+ assert NullHandling.replaceWithDefault();
Review comment:
unable to find the discussion among lots of review comments.
I believe the intent here was to catch any coding errors/places where we may
have missed handling nulls properly.
@leventov: can probably add more context here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]