-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-29213][SQL] Generate extra IsNotNull predicate in FilterExec #25902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ad6df5c
270172b
9ad9723
c03dd95
30e2ac7
8480de2
a8cb828
124ad87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ package org.apache.spark.sql.execution | |
|
|
||
| import java.util.concurrent.TimeUnit._ | ||
|
|
||
| import scala.collection.mutable | ||
| import scala.concurrent.{ExecutionContext, Future} | ||
| import scala.concurrent.duration.Duration | ||
|
|
||
|
|
@@ -110,7 +111,6 @@ case class FilterExec(condition: Expression, child: SparkPlan) | |
|
|
||
| // The columns that will filtered out by `IsNotNull` could be considered as not nullable. | ||
| private val notNullAttributes = notNullPreds.flatMap(_.references).distinct.map(_.exprId) | ||
| .diff(otherPreds.flatMap(_.references).distinct.map(_.exprId)) | ||
|
|
||
| // 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. | ||
|
|
@@ -172,13 +172,23 @@ case class FilterExec(condition: Expression, child: SparkPlan) | |
| // This is very perf sensitive. | ||
| // TODO: revisit this. We can consider reordering predicates as well. | ||
| val generatedIsNotNullChecks = new Array[Boolean](notNullPreds.length) | ||
|
|
||
| val extraIsNotNullReferences = mutable.Set[Attribute]() | ||
|
|
||
| def outputContainsNotNull(ref: Attribute): Boolean = { | ||
|
||
| output.exists { attr => attr.exprId == ref.exprId } | ||
| } | ||
|
|
||
| val generated = otherPreds.map { c => | ||
| val nullChecks = c.references.map { r => | ||
| val idx = notNullPreds.indexWhere { n => n.asInstanceOf[IsNotNull].child.semanticEquals(r)} | ||
| if (idx != -1 && !generatedIsNotNullChecks(idx)) { | ||
| generatedIsNotNullChecks(idx) = true | ||
| // Use the child's output. The nullability is what the child produced. | ||
| genPredicate(notNullPreds(idx), input, child.output) | ||
| } else if (outputContainsNotNull(r) && !extraIsNotNullReferences.contains(r)) { | ||
| extraIsNotNullReferences += r | ||
| genPredicate(IsNotNull(r), input, child.output) | ||
| } else { | ||
| "" | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
extraIsNotNullAttrs