Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ case class Filter(condition: Expression, child: SparkPlan)

// Split out all the IsNotNulls from condition.
private val (notNullPreds, otherPreds) = splitConjunctivePredicates(condition).partition {
case IsNotNull(a) if child.output.exists(_.semanticEquals(a)) => true
case IsNotNull(a: NullIntolerant) if a.references.subsetOf(child.outputSet) => true
case _ => false
}

// The columns that will filtered out by `IsNotNull` could be considered as not nullable.
private val notNullAttributes = notNullPreds.flatMap(_.references)
private val notNullAttributes = notNullPreds.flatMap(_.references).distinct.map(_.exprId)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attributes from conditions can have different qualifiers than child.output, which makes later indexOf call failed. So here use exprId instead.


// Mark this as empty. We'll evaluate the input during doConsume(). We don't want to evaluate
// all the variables at the beginning to take advantage of short circuiting.
override def usedInputs: AttributeSet = AttributeSet.empty

override def output: Seq[Attribute] = {
child.output.map { a =>
if (a.nullable && notNullAttributes.exists(_.semanticEquals(a))) {
if (a.nullable && notNullAttributes.contains(a.exprId)) {
a.withNullability(false)
} else {
a
Expand Down Expand Up @@ -179,7 +179,7 @@ case class Filter(condition: Expression, child: SparkPlan)
// Reset the isNull to false for the not-null columns, then the followed operators could
// generate better code (remove dead branches).
val resultVars = input.zipWithIndex.map { case (ev, i) =>
if (notNullAttributes.exists(_.semanticEquals(child.output(i)))) {
if (notNullAttributes.contains(child.output(i).exprId)) {
ev.isNull = "false"
}
ev
Expand Down