clintropolis commented on a change in pull request #10370:
URL: https://github.com/apache/druid/pull/10370#discussion_r486757634



##########
File path: core/src/main/java/org/apache/druid/math/expr/UnaryOperatorExpr.java
##########
@@ -163,4 +171,15 @@ public String toString()
   {
     return StringUtils.format("!%s", expr);
   }
+
+  @Nullable
+  @Override
+  public ExprType getOutputType(InputBindingTypes inputTypes)
+  {
+    ExprType implicitCast = super.getOutputType(inputTypes);
+    if (ExprType.STRING.equals(implicitCast)) {
+      return ExprType.LONG;
+    }

Review comment:
       I don't know off the top of my head why it does that, I was just trying 
to model its output. The binary logic expressions do that too:
   ```
     @Override
     protected ExprEval evalString(@Nullable String left, @Nullable String 
right)
     {
       return 
ExprEval.ofLongBoolean(Comparators.<String>naturalNullsFirst().compare(left, 
right) < 0);
     }
   ```
   so it is just being consistent with those operators I think.
   
   I'm moderately in the camp of wondering why these logical operators return 
anything other than long for any input type, but I haven't thought fully 
through on the implications of changing that yet, so maybe there is a reason 
that the type is preserved for doubles in these operators.




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to