Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Address some comments
  • Loading branch information
wangshuo128 committed Sep 27, 2019
commit 8480de279f283d0f5a8437f91a43b4e8a23e82b9
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ case class FilterExec(condition: Expression, child: SparkPlan)
// 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 extraIsNotNullAttrs = mutable.Set[Attribute]()

val generated = otherPreds.map { c =>
val nullChecks = c.references.map { r =>
Expand All @@ -186,8 +182,8 @@ case class FilterExec(condition: Expression, child: SparkPlan)
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
} else if (notNullAttributes.contains(r.exprId) && !extraIsNotNullAttrs.contains(r)) {
extraIsNotNullAttrs += r
genPredicate(IsNotNull(r), input, child.output)
} else {
""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3234,8 +3234,7 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession {
}
}

test("SPARK-29213 Make it consistent when get notnull output and generate null " +
"checks in FilterExec") {
test("SPARK-29213: FilterExec should not throw NPE") {
withView("t1", "t2", "t3") {
Copy link
Member

Choose a reason for hiding this comment

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

nit: withView -> withTempView

sql("select ''").as[String].map(identity).toDF("x").createOrReplaceTempView("t1")
sql("select * from values 0, cast(null as bigint)")
Expand Down