Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/22029#discussion_r229699828
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
---
@@ -339,37 +371,57 @@ case class In(value: Expression, list:
Seq[Expression]) extends Predicate {
* Optimized version of In clause, when all filter values of In clause are
* static.
*/
-case class InSet(child: Expression, hset: Set[Any]) extends
UnaryExpression with Predicate {
+case class InSet(values: Seq[Expression], hset: Set[Any]) extends InBase {
require(hset != null, "hset could not be null")
- override def toString: String = s"$child INSET ${hset.mkString("(", ",",
")")}"
+ override def toString: String = s"$value INSET ${hset.mkString("(", ",",
")")}"
- @transient private[this] lazy val hasNull: Boolean = hset.contains(null)
+ override def children: Seq[Expression] = values
- override def nullable: Boolean = child.nullable || hasNull
+ @transient private[this] lazy val hasNull: Boolean = {
+ if (isMultiValued && !SQLConf.get.inFalseForNullField) {
+ hset.exists(checkNullEval)
+ } else {
+ hset.contains(null)
+ }
+ }
- protected override def nullSafeEval(value: Any): Any = {
- if (set.contains(value)) {
- true
- } else if (hasNull) {
+ override def nullable: Boolean = {
+ val isValueNullable = if (isMultiValued &&
!SQLConf.get.inFalseForNullField) {
+ values.exists(_.nullable)
+ } else {
+ value.nullable
+ }
+ isValueNullable || hasNull
+ }
+
+ override def eval(input: InternalRow): Any = {
+ val inputValue = value.eval(input)
+ if (checkNullEval(inputValue)) {
--- End diff --
do we change behavior here? seems `null inset (null, xxx)` returns true
previously.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]