Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/7157#discussion_r33864982
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
---
@@ -167,6 +167,25 @@ abstract class BinaryExpression extends Expression
with trees.BinaryNode[Express
override def toString: String = s"($left $symbol $right)"
+ // Default behavior of evaluation according to the default nullability
of BinaryExpression.
+ // If subclass of BinaryExpression override nullable, probably should
also override this.
+ override def eval(input: InternalRow): Any = {
+ val evalE1 = left.eval(input)
+ if(evalE1 == null) {
+ null
+ } else {
+ val evalE2 = right.eval(input)
+ if (evalE2 == null) {
+ null
+ } else {
+ nullSafeEval(evalE1, evalE2)
+ }
+ }
+ }
+
+ protected def nullSafeEval(evalE1: Any, evalE2: Any): Any =
+ sys.error(s"BinaryExpressions must override either eval or
nullSafeEval")
--- End diff --
There maybe exceptional cases that user need to override `eval`, at that
time they don't need to implement `nullSafeEval`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]