MaxGekk commented on a change in pull request #34257:
URL: https://github.com/apache/spark/pull/34257#discussion_r727455244
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ArithmeticExpressionSuite.scala
##########
@@ -699,4 +699,26 @@ class ArithmeticExpressionSuite extends SparkFunSuite with
ExpressionEvalHelper
checkConsistencyBetweenInterpretedAndCodegen((e: Expression) => Abs(e,
false), tpe)
}
}
+
+ test("SPARK-36921: Support AnsiIntervalType by div") {
+ checkEvaluation(IntegralDivide(Literal(Period.ZERO),
Literal(Period.ZERO)), null)
+ checkEvaluation(IntegralDivide(Literal(Period.ZERO),
+ Literal(Period.ofYears(1))), 0L)
+ checkEvaluation(IntegralDivide(Literal(Period.ofYears(2)),
+ Literal(Period.ofYears(1))), 2L)
+ checkEvaluation(IntegralDivide(Literal(Period.ofYears(1)),
+ Literal(Period.ofMonths(3))), 4L)
+ checkEvaluation(IntegralDivide(Literal(Period.ofYears(1)),
Review comment:
Could you check negative intervals, and also some corner cases like
division by max/min and zero intervals.
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ArithmeticExpressionSuite.scala
##########
@@ -699,4 +699,26 @@ class ArithmeticExpressionSuite extends SparkFunSuite with
ExpressionEvalHelper
checkConsistencyBetweenInterpretedAndCodegen((e: Expression) => Abs(e,
false), tpe)
}
}
+
+ test("SPARK-36921: Support AnsiIntervalType by div") {
+ checkEvaluation(IntegralDivide(Literal(Period.ZERO),
Literal(Period.ZERO)), null)
+ checkEvaluation(IntegralDivide(Literal(Period.ZERO),
+ Literal(Period.ofYears(1))), 0L)
+ checkEvaluation(IntegralDivide(Literal(Period.ofYears(2)),
+ Literal(Period.ofYears(1))), 2L)
+ checkEvaluation(IntegralDivide(Literal(Period.ofYears(1)),
+ Literal(Period.ofMonths(3))), 4L)
+ checkEvaluation(IntegralDivide(Literal(Period.ofYears(1)),
Review comment:
Could you check negative intervals, and also some corner cases like
division by max/min and zero intervals (ArithmeticExpressionSuite).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]