ANSI integral SUM overflow reports "integer overflow" without Spark's try_add suggestion
Los mantenedores suelen responder en 2 días
@0lai0 ya está trabajando en esto.
Desde el 6/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
Línea de trabajo
Empieza por native/spark-expr/src/agg_funcs/sum_int.rs y los tres puntos de desbordamiento descritos en la issue; después, lee la prueba existente ANSI support - SUM function en CometAggregateSuite. Compara los parámetros de error de Comet con los de Spark para las rutas de desbordamiento tanto de update como de merge. La tarea estará terminada cuando los parámetros message y alternative coincidan con los de Spark y la prueba verifique esa comparación.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
Under spark.sql.ansi.enabled=true, an integral SUM overflow in Comet raises ARITHMETIC_OVERFLOW with the message parameter integer overflow and an empty alternative. Spark raises long overflow with the suggestion Use 'try_add' to tolerate overflow and return NULL instead.
Spark's SUM over integral input always returns LONG, and Sum adds through Add(left, right, evalContext) in both its update and merge expressions. So the overflow goes through MathUtils.addExact(Long, Long, context) with the try_add hint, the same on 3.4.3 through 4.2.0. Comet's native/spark-expr/src/agg_funcs/sum_int.rs raises arithmetic_overflow_error("integer") at its three overflow sites: the ungrouped update (which the ungrouped merge reuses), the grouped update, and the grouped merge.
Comet's decision to throw matches Spark. Only the message parameters differ, which matters to code that inspects getMessageParameters() or the message text.
This was part of item 2 in #5071, which also named SumInteger. #6217 assumed the rest of #5071 had been fixed, and #6249 fixes the binary +, - and * kernels but not SUM. Once #6249 removes the #6217 bullet, the compatibility guide no longer lists this divergence.
Steps to reproduce
SET spark.sql.ansi.enabled=true;
CREATE TABLE t (l BIGINT) USING parquet;
INSERT INTO t SELECT CASE WHEN id = 0 THEN 9223372036854775807 ELSE 1 END FROM range(0, 3, 1, 1);
SELECT SUM(l) FROM t;
-- Spark: [ARITHMETIC_OVERFLOW] long overflow. Use 'try_add' to tolerate overflow and return NULL instead. If necessary set "spark.sql.ansi.enabled" to "false" to bypass this error.
-- Comet: [ARITHMETIC_OVERFLOW] integer overflow. If necessary set "spark.sql.ansi.enabled" to "false" to bypass this error.
The final merge diverges the same way when each of two partitions holds part of the overflowing sum.
Expected behavior
The message parameter is long overflow and alternative carries the try_add suggestion, as in Spark.
Additional context
Reproduced locally on Spark 3.4 and 4.1 for both the partial and the merge path. With the function_name field that #6249 adds to SparkError::ArithmeticOverflow, raising ArithmeticOverflow { from_type: "long", function_name: "try_add" } at the three call sites made Comet match Spark's error class, parameters and message on both paths.
The existing ANSI support - SUM function test in CometAggregateSuite only checks that both messages contain ARITHMETIC_OVERFLOW, so it passes either way. It should compare the message parameters with Spark's.
- Lenguaje dominante
- Scala
- Estrellas
- 1.3k
- Forks
- 398
- Merge medio
- 3 d 3 h
- PR fusionados (30 d)
- 400
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/datafusion-comet
-
requires-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/datafusion-comet#7240 ·
Los mantenedores suelen responder en 2 días
-
bug priority:low
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
apache/datafusion-comet#7176 ·
Los mantenedores suelen responder en 2 días
-
enhancement
Dificultad 1/5 1-3 horas Aptitud para principiantes 83/100
apache/datafusion-comet#7101 ·
Los mantenedores suelen responder en 2 días
-
requires-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
apache/datafusion-comet#7001 ·
Los mantenedores suelen responder en 2 días
-
Deduplicate spark_ceil and spark_floor and port floor's decimal boundary tests to ceilQuizá libre de nuevo @med9110 la tomó hace 12 días y no hay ningún pull request abierto. Abiertoarea:expressions enhancement help wanted requires-triage rust tech debt
Dificultad 2/5 Medio día Aptitud para principiantes 68/100
apache/datafusion-comet#6974 · 1 comentario ·
Los mantenedores suelen responder en 2 días
Todos los issues de apache/datafusion-comet
Issues similares
-
bug 🐞 Untriaged user issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
valkey-io/valkey-glide#7443 ·
Los mantenedores suelen responder en 1 día
-
A-api C-bug S-ready-for-human
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
ergoplatform/ergo#2851 ·
Los mantenedores suelen responder en 2 días
-
? - Needs Triage audit_4.2.0 feature request test
Dificultad 2/5 1-3 horas Aptitud para principiantes 87/100
NVIDIA/cudf-spark#16614 ·
Los mantenedores suelen responder en 1 día
-
bug unit testing velox backend
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día