diff options
Diffstat (limited to 'sql/catalyst/src/main')
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala | 110 | ||||
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala | 4 |
2 files changed, 0 insertions, 114 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala index 7ff8795d4f..77d40a5079 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala @@ -361,116 +361,6 @@ case class Remainder(left: Expression, right: Expression) } } -case class MaxOf(left: Expression, right: Expression) - extends BinaryArithmetic with NonSQLExpression { - - // TODO: Remove MaxOf and MinOf, and replace its usage with Greatest and Least. - - override def inputType: AbstractDataType = TypeCollection.Ordered - - override def nullable: Boolean = left.nullable && right.nullable - - private lazy val ordering = TypeUtils.getInterpretedOrdering(dataType) - - override def eval(input: InternalRow): Any = { - val input1 = left.eval(input) - val input2 = right.eval(input) - if (input1 == null) { - input2 - } else if (input2 == null) { - input1 - } else { - if (ordering.compare(input1, input2) < 0) { - input2 - } else { - input1 - } - } - } - - override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { - val eval1 = left.genCode(ctx) - val eval2 = right.genCode(ctx) - val compCode = ctx.genComp(dataType, eval1.value, eval2.value) - - ev.copy(code = eval1.code + eval2.code + s""" - boolean ${ev.isNull} = false; - ${ctx.javaType(left.dataType)} ${ev.value} = - ${ctx.defaultValue(left.dataType)}; - - if (${eval1.isNull}) { - ${ev.isNull} = ${eval2.isNull}; - ${ev.value} = ${eval2.value}; - } else if (${eval2.isNull}) { - ${ev.isNull} = ${eval1.isNull}; - ${ev.value} = ${eval1.value}; - } else { - if ($compCode > 0) { - ${ev.value} = ${eval1.value}; - } else { - ${ev.value} = ${eval2.value}; - } - }""") - } - - override def symbol: String = "max" -} - -case class MinOf(left: Expression, right: Expression) - extends BinaryArithmetic with NonSQLExpression { - - // TODO: Remove MaxOf and MinOf, and replace its usage with Greatest and Least. - - override def inputType: AbstractDataType = TypeCollection.Ordered - - override def nullable: Boolean = left.nullable && right.nullable - - private lazy val ordering = TypeUtils.getInterpretedOrdering(dataType) - - override def eval(input: InternalRow): Any = { - val input1 = left.eval(input) - val input2 = right.eval(input) - if (input1 == null) { - input2 - } else if (input2 == null) { - input1 - } else { - if (ordering.compare(input1, input2) < 0) { - input1 - } else { - input2 - } - } - } - - override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { - val eval1 = left.genCode(ctx) - val eval2 = right.genCode(ctx) - val compCode = ctx.genComp(dataType, eval1.value, eval2.value) - - ev.copy(code = eval1.code + eval2.code + s""" - boolean ${ev.isNull} = false; - ${ctx.javaType(left.dataType)} ${ev.value} = - ${ctx.defaultValue(left.dataType)}; - - if (${eval1.isNull}) { - ${ev.isNull} = ${eval2.isNull}; - ${ev.value} = ${eval2.value}; - } else if (${eval2.isNull}) { - ${ev.isNull} = ${eval1.isNull}; - ${ev.value} = ${eval1.value}; - } else { - if ($compCode < 0) { - ${ev.value} = ${eval1.value}; - } else { - ${ev.value} = ${eval2.value}; - } - }""") - } - - override def symbol: String = "min" -} - @ExpressionDescription( usage = "_FUNC_(a, b) - Returns the positive modulo", extended = "> SELECT _FUNC_(10,3);\n 1") diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala index fe328fd598..75130007b9 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala @@ -662,10 +662,6 @@ object NullPropagation extends Rule[LogicalPlan] { case e @ Substring(_, Literal(null, _), _) => Literal.create(null, e.dataType) case e @ Substring(_, _, Literal(null, _)) => Literal.create(null, e.dataType) - // MaxOf and MinOf can't do null propagation - case e: MaxOf => e - case e: MinOf => e - // Put exceptional cases above if any case e @ BinaryArithmetic(Literal(null, _), _) => Literal.create(null, e.dataType) case e @ BinaryArithmetic(_, Literal(null, _)) => Literal.create(null, e.dataType) |