Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
yaooqinn committed Dec 24, 2019
commit 729337756261a26a2dc376ede9db05a52f238c76
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ case class UnaryMinus(child: Expression) extends UnaryExpression
private val checkOverflow = SQLConf.get.ansiEnabled

override def nullable: Boolean = dataType match {
case CalendarIntervalType if !checkOverflow => true
case _ => super.nullable
case CalendarIntervalType => true
case _ => child.nullable
}

override def inputTypes: Seq[AbstractDataType] = Seq(TypeCollection.NumericAndInterval)
Expand Down Expand Up @@ -97,11 +97,11 @@ case class UnaryMinus(child: Expression) extends UnaryExpression
case CalendarIntervalType =>
try {
IntervalUtils.negate(input.asInstanceOf[CalendarInterval])
} catch {
case _: ArithmeticException if checkOverflow =>
throw new ArithmeticException(s"$sql caused interval overflow")
case _: ArithmeticException => null
}
} catch {
case _: ArithmeticException if checkOverflow =>
throw new ArithmeticException(s"$sql caused interval overflow")
case _: ArithmeticException => null
}
case _ => numeric.negate(input)
}

Expand Down Expand Up @@ -253,7 +253,7 @@ object BinaryArithmetic {
case class Add(left: Expression, right: Expression) extends BinaryArithmetic {

override def nullable: Boolean = dataType match {
case CalendarIntervalType if !checkOverflow => true
case CalendarIntervalType => true
case _ => super.nullable
}

Expand Down Expand Up @@ -293,7 +293,7 @@ case class Add(left: Expression, right: Expression) extends BinaryArithmetic {
case class Subtract(left: Expression, right: Expression) extends BinaryArithmetic {

override def nullable: Boolean = dataType match {
case CalendarIntervalType if !checkOverflow => true
case CalendarIntervalType => true
case _ => super.nullable
}

Expand Down