File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
main/scala/org/apache/spark/sql/catalyst/optimizer
test/scala/org/apache/spark/sql/catalyst/optimizer Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -443,11 +443,12 @@ object SimplifyConditionals extends Rule[LogicalPlan] with PredicateHelper {
443443 private def isRedundantNullCheck (
444444 ifNullExpr : Expression ,
445445 ifNotNullExpr : Expression ,
446- checkedExpr : Expression ): Boolean = ifNotNullExpr match {
447- case e : NullIntolerant if (
448- (ifNullExpr == checkedExpr || ifNullExpr == Literal .create(null , checkedExpr.dataType))
449- && e.children.contains(checkedExpr)) => true
450- case _ => false
446+ checkedExpr : Expression ): Boolean = {
447+ ifNotNullExpr.isInstanceOf [NullIntolerant ] && {
448+ (ifNullExpr.semanticEquals(checkedExpr) ||
449+ (ifNullExpr.foldable && ifNullExpr.eval() == null )) &&
450+ ifNotNullExpr.children.contains(checkedExpr)
451+ }
451452 }
452453
453454 def apply (plan : LogicalPlan ): LogicalPlan = plan transform {
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import org.apache.spark.sql.catalyst.dsl.expressions._
2222import org .apache .spark .sql .catalyst .dsl .plans ._
2323import org .apache .spark .sql .catalyst .expressions ._
2424import org .apache .spark .sql .catalyst .expressions .Literal .{FalseLiteral , TrueLiteral }
25- import org .apache .spark .sql .catalyst .plans .{ PlanTest }
25+ import org .apache .spark .sql .catalyst .plans .PlanTest
2626import org .apache .spark .sql .catalyst .plans .logical .{LocalRelation , LogicalPlan , Project }
2727import org .apache .spark .sql .catalyst .rules .RuleExecutor
2828import org .apache .spark .sql .types .{IntegerType , NullType }
You can’t perform that action at this time.
0 commit comments