@@ -95,8 +95,8 @@ object NullPropagation extends Rule[LogicalPlan] {
9595 def apply (plan : LogicalPlan ): LogicalPlan = plan transform {
9696 case q : LogicalPlan => q transformExpressionsUp {
9797 case e @ Count (Literal (null , _)) => Literal (0 , e.dataType)
98- case e @ Sum (Literal (c, _)) if ( c == 0 ) => Literal (0 , e.dataType)
99- case e @ Average (Literal (c, _)) if ( c == 0 ) => Literal (0.0 , e.dataType)
98+ case e @ Sum (Literal (c, _)) if c == 0 => Literal (0 , e.dataType)
99+ case e @ Average (Literal (c, _)) if c == 0 => Literal (0.0 , e.dataType)
100100 case e @ IsNull (c) if c.nullable == false => Literal (false , BooleanType )
101101 case e @ IsNotNull (c) if c.nullable == false => Literal (true , BooleanType )
102102 case e @ GetItem (Literal (null , _), _) => Literal (null , e.dataType)
@@ -107,17 +107,17 @@ object NullPropagation extends Rule[LogicalPlan] {
107107 case Literal (null , _) => false
108108 case _ => true
109109 })
110- if (newChildren.length == 0 ) {
110+ if (newChildren.length == 0 ) {
111111 Literal (null , e.dataType)
112- } else if (newChildren.length == 1 ) {
112+ } else if (newChildren.length == 1 ) {
113113 newChildren(0 )
114114 } else {
115115 Coalesce (newChildren)
116116 }
117117 }
118- case e @ If (Literal (v, _), trueValue, falseValue) => if (v == true ) trueValue else falseValue
119- case e @ In (Literal (v, _), list) if (list.exists(c => c match {
120- case Literal (candidate, _) if ( candidate == v) => true
118+ case e @ If (Literal (v, _), trueValue, falseValue) => if (v == true ) trueValue else falseValue
119+ case e @ In (Literal (v, _), list) if (list.exists(c => c match {
120+ case Literal (candidate, _) if candidate == v => true
121121 case _ => false
122122 })) => Literal (true , BooleanType )
123123 case e : UnaryMinus => e.child match {
@@ -151,6 +151,7 @@ object NullPropagation extends Rule[LogicalPlan] {
151151 }
152152 }
153153}
154+
154155/**
155156 * Replaces [[catalyst.expressions.Expression Expressions ]] that can be statically evaluated with
156157 * equivalent [[catalyst.expressions.Literal Literal ]] values.
0 commit comments