Skip to content

Commit 0402bd7

Browse files
ueshinmarmbrus
authored andcommitted
[SPARK-2093] [SQL] NullPropagation should use exact type value.
`NullPropagation` should use exact type value when transform `Count` or `Sum`. Author: Takuya UESHIN <[email protected]> Closes apache#1034 from ueshin/issues/SPARK-2093 and squashes the following commits: 65b6ff1 [Takuya UESHIN] Modify the literal value of the result of transformation from Sum to long value. 830c20b [Takuya UESHIN] Add Cast to the result of transformation from Count. 9314806 [Takuya UESHIN] Fix NullPropagation to use exact type value.
1 parent 601032f commit 0402bd7

File tree

1 file changed

+2
-2
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer

1 file changed

+2
-2
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ object ColumnPruning extends Rule[LogicalPlan] {
104104
object NullPropagation extends Rule[LogicalPlan] {
105105
def apply(plan: LogicalPlan): LogicalPlan = plan transform {
106106
case q: LogicalPlan => q transformExpressionsUp {
107-
case e @ Count(Literal(null, _)) => Literal(0, e.dataType)
108-
case e @ Sum(Literal(c, _)) if c == 0 => Literal(0, e.dataType)
107+
case e @ Count(Literal(null, _)) => Cast(Literal(0L), e.dataType)
108+
case e @ Sum(Literal(c, _)) if c == 0 => Cast(Literal(0L), e.dataType)
109109
case e @ Average(Literal(c, _)) if c == 0 => Literal(0.0, e.dataType)
110110
case e @ IsNull(c) if c.nullable == false => Literal(false, BooleanType)
111111
case e @ IsNotNull(c) if c.nullable == false => Literal(true, BooleanType)

0 commit comments

Comments
 (0)