Skip to content

Commit 8cebd01

Browse files
committed
rebase
1 parent ef6f27f commit 8cebd01

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

native/core/src/common/bit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ impl BitReader {
671671
}
672672
}
673673

674-
debug_assert!(!(offset + i).is_multiple_of(8)|| num_bits_to_read - i < 8);
674+
debug_assert!(!(offset + i).is_multiple_of(8) || num_bits_to_read - i < 8);
675675

676676
// Now copy the remaining bits if there's any.
677677
while i < num_bits_to_read {

spark/src/main/scala/org/apache/comet/serde/arithmetic.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ object CometIntegralDivide extends CometExpressionSerde[IntegralDivide] with Mat
185185
inputs: Seq[Attribute],
186186
binding: Boolean): Option[ExprOuterClass.Expr] = {
187187

188-
if (!supportedDataType(expr.left.dataType)) {
189-
withInfo(expr, s"Unsupported datatype ${expr.left.dataType}")
190-
return None
191-
}
192-
193188
// Precision is set to 19 (max precision for a numerical data type except DecimalType)
194189

195190
val left =
@@ -199,7 +194,8 @@ object CometIntegralDivide extends CometExpressionSerde[IntegralDivide] with Mat
199194
if (expr.right.dataType.isInstanceOf[DecimalType]) expr.right
200195
else Cast(expr.right, DecimalType(19, 0))
201196

202-
val rightExpr = nullIfWhenPrimitive(right)
197+
val rightExpr =
198+
if (expr.evalMode != EvalMode.ANSI) nullIfWhenPrimitive(right) else right
203199

204200
val dataType = (left.dataType, right.dataType) match {
205201
case (l: DecimalType, r: DecimalType) =>

spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
4949
val ARITHMETIC_OVERFLOW_EXCEPTION_MSG =
5050
"""org.apache.comet.CometNativeException: [ARITHMETIC_OVERFLOW] integer overflow. If necessary set "spark.sql.ansi.enabled" to "false" to bypass this error."""
5151

52+
val DIVIDE_BY_ZERO_ERROR =
53+
"""[DIVIDE_BY_ZERO] Division by zero. Use `try_divide` to tolerate divisor being 0 and return NULL instead"""
54+
5255
override protected def test(testName: String, testTags: Tag*)(testFun: => Any)(implicit
5356
pos: Position): Unit = {
5457
super.test(testName, testTags: _*) {
@@ -469,9 +472,7 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
469472

470473
checkSparkMaybeThrows(res) match {
471474
case (Some(sparkExc), Some(cometExc)) =>
472-
val cometErrorPattern =
473-
"""org.apache.comet.CometNativeException: [DIVIDE_BY_ZERO] Division by zero. Use `try_divide` to tolerate divisor being 0 and return NULL instead"""
474-
assert(cometExc.getMessage.contains(cometErrorPattern))
475+
assert(cometExc.getMessage.contains(DIVIDE_BY_ZERO_ERROR))
475476
assert(sparkExc.getMessage.contains("Division by zero"))
476477
case _ => fail("Exception should be thrown")
477478
}
@@ -492,9 +493,7 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
492493

493494
checkSparkMaybeThrows(res) match {
494495
case (Some(sparkExc), Some(cometExc)) =>
495-
val cometErrorPattern =
496-
"""[DIVIDE_BY_ZERO] Division by zero. Use `try_divide` to tolerate divisor being 0 and return NULL instead"""
497-
assert(cometExc.getMessage.contains(cometErrorPattern))
496+
assert(cometExc.getMessage.contains(DIVIDE_BY_ZERO_ERROR))
498497
assert(sparkExc.getMessage.contains("Division by zero"))
499498
case _ => fail("Exception should be thrown")
500499
}
@@ -515,9 +514,7 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
515514

516515
checkSparkMaybeThrows(res) match {
517516
case (Some(sparkExc), Some(cometExc)) =>
518-
val cometErrorPattern =
519-
"""[DIVIDE_BY_ZERO] Division by zero. Use `try_divide` to tolerate divisor being 0 and return NULL instead"""
520-
assert(cometExc.getMessage.contains(cometErrorPattern))
517+
assert(cometExc.getMessage.contains(DIVIDE_BY_ZERO_ERROR))
521518
assert(sparkExc.getMessage.contains("Division by zero"))
522519
case _ => fail("Exception should be thrown")
523520
}

0 commit comments

Comments
 (0)