Skip to content

Commit 7e54ccb

Browse files
committed
[SPARK-29213] Make it consistent when get notnull output and generate null checks in FilteExec
1 parent f725d47 commit 7e54ccb

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/basicPhysicalOperators.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ case class FilterExec(condition: Expression, child: SparkPlan)
117117

118118
override def output: Seq[Attribute] = {
119119
child.output.map { a =>
120-
if (a.nullable && notNullAttributes.contains(a.exprId)) {
120+
if (a.nullable && notNullPreds.exists(_.semanticEquals(a))) {
121121
a.withNullability(false)
122122
} else {
123123
a

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,4 +2412,29 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
24122412
}
24132413
}
24142414
}
2415+
2416+
test("SPARK-29213 Make it consistent when get notnull output and generate null " +
2417+
"checks in FilterExec") {
2418+
withTable("table1", "table2", "table3") {
2419+
sql("create table table1(x string)")
2420+
sql("create table table2(x bigint)")
2421+
sql("create table table3(x string)")
2422+
sql("insert into table2 select null as x")
2423+
sql(
2424+
"""
2425+
|select t1.x
2426+
|from (
2427+
| select x from table1) t1
2428+
|left join (
2429+
| select x from (
2430+
| select x from table2
2431+
| union all
2432+
| select substr(x,5) x from table3
2433+
| ) a
2434+
| where length(x)>0
2435+
|) t3
2436+
|on t1.x=t3.x
2437+
""".stripMargin).collect()
2438+
}
2439+
}
24152440
}

0 commit comments

Comments
 (0)