Skip to content

Commit 516080c

Browse files
committed
override nullable, fix tests
1 parent 829cfe7 commit 516080c

File tree

1 file changed

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

1 file changed

+10
-2
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ abstract class BinaryArithmetic extends BinaryOperator with NullIntolerant {
158158

159159
override def dataType: DataType = left.dataType
160160

161-
override def nullable: Boolean = true
162-
163161
override lazy val resolved: Boolean = childrenResolved && checkInputDataTypes().isSuccess
164162

165163
/** Name of the function for this expression on a [[Decimal]] type. */
@@ -251,6 +249,11 @@ object BinaryArithmetic {
251249
""")
252250
case class Add(left: Expression, right: Expression) extends BinaryArithmetic {
253251

252+
override def nullable: Boolean = dataType match {
253+
case CalendarIntervalType if !checkOverflow => true
254+
case _ => super.nullable
255+
}
256+
254257
override def inputType: AbstractDataType = TypeCollection.NumericAndInterval
255258

256259
override def symbol: String = "+"
@@ -286,6 +289,11 @@ case class Add(left: Expression, right: Expression) extends BinaryArithmetic {
286289
""")
287290
case class Subtract(left: Expression, right: Expression) extends BinaryArithmetic {
288291

292+
override def nullable: Boolean = dataType match {
293+
case CalendarIntervalType if !checkOverflow => true
294+
case _ => false
295+
}
296+
289297
override def inputType: AbstractDataType = TypeCollection.NumericAndInterval
290298

291299
override def symbol: String = "-"

0 commit comments

Comments
 (0)