clintropolis commented on a change in pull request #10370:
URL: https://github.com/apache/druid/pull/10370#discussion_r488324915
##########
File path:
core/src/main/java/org/apache/druid/math/expr/BinaryLogicalOperatorExpr.java
##########
@@ -57,6 +57,17 @@ protected final double evalDouble(double left, double right)
// Use Double.compare for more consistent NaN handling.
return Evals.asDouble(Double.compare(left, right) < 0);
}
+
+ @Nullable
+ @Override
+ public ExprType getOutputType(InputBindingTypes inputTypes)
+ {
+ ExprType implicitCast = super.getOutputType(inputTypes);
+ if (ExprType.STRING.equals(implicitCast)) {
+ return ExprType.LONG;
+ }
+ return implicitCast;
Review comment:
I'm going to merge this PR, but we can continue this discussion in the
next one, so this stuff can actually be tied into things in a concrete manner.
Looking at postgres, its math functions do, at least somewhat, allow for
implicit conversion of sting numbers to numbers. So `2.0 + '3.1' = 5.1` and
`cos('1')` work, but `'2.0' + '3.1'` does not. In druid currently the first
would have the same behavior as postgres, but the 2nd would be null or 0
depending on the value of `druid.generic.useDefaultValueForNull`, while the 3rd
expression would do string concatenation.
----------------------------------------------------------------
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]