`repeat` on `LargeUtf8` aborts the process on a result size no allocation can satisfy
Los mantenedores suelen responder en 1 día
@huong8373tt-beep ya está trabajando en esto.
Desde el 2/11/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
Línea de trabajo
Comienza en datafusion/functions/src/string/repeat.rs, comparando el límite de LargeUtf8 en la ruta escalar cerca de las líneas 127-128 con la ruta de array cerca de las líneas 227-228. Lee test_repeat_string_array_overflow y el fragmento de reproducción, luego elige el enfoque de tope fijo o try_reserve y haz que ambas rutas devuelvan un error para un conteo de 1 << 60. Añade una prueba de regresión que cubra el LargeUtf8 escalar y el constructor de arrays, y ejecuta las pruebas de repeat.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
repeat on LargeUtf8 aborts the process on a result size no allocation can satisfy
Describe the bug
repeat caps the result at i32::MAX bytes for Utf8 and Utf8View, and returns an error above that. For LargeUtf8 the cap is i64::MAX, in both the scalar path and the array path. That cap admits sizes no allocation can satisfy. A result of 2^60 bytes (1 EiB) is larger than the virtual address space of x86_64 (48 or 57 bits) and aarch64 (at most 52 bits), so the allocator refuses it at once, whatever memory the machine has:
- With both arguments scalar,
s.repeat(count)cannot fail gracefully, so the refused allocation aborts the process:memory allocation of 1152921504606846976 bytes failed. - With an array of strings, the builder panics:
failed to allocate memory for layout Layout { size: 1152921504606846976, align: 64 (1 << 6) }.
The existing test_repeat_string_array_overflow uses a count of i64::MAX, which the overflow check catches before any allocation.
To Reproduce
On main at 926901f90:
use std::sync::Arc;
use arrow::datatypes::Field;
use datafusion_common::ScalarValue;
use datafusion_common::config::ConfigOptions;
use datafusion_expr::{ColumnarValue, ReturnFieldArgs, ScalarFunctionArgs};
use datafusion_functions::string::repeat;
let udf = repeat();
let s = ScalarValue::LargeUtf8(Some("a".to_string()));
// With ScalarValue::Utf8: Err(Execution("string size overflow on repeat, max size is 2147483647, but got 1152921504606846976"))
let n = ScalarValue::Int64(Some(1 << 60));
let arg_fields = vec![
Arc::new(Field::new("s", s.data_type(), true)),
Arc::new(Field::new("n", n.data_type(), true)),
];
let return_field = udf
.return_field_from_args(ReturnFieldArgs {
arg_fields: &arg_fields,
scalar_arguments: &[Some(&s), Some(&n)],
})
.unwrap();
let result = udf.invoke_with_args(ScalarFunctionArgs {
args: vec![ColumnarValue::Scalar(s), ColumnarValue::Scalar(n)],
arg_fields,
number_rows: 1,
return_field,
config_options: Arc::new(ConfigOptions::default()),
});
// aborts: memory allocation of 1152921504606846976 bytes failed
Expected behavior
An error, as for Utf8, instead of an abort. Two fixes seem possible:
- A fixed cap for
LargeUtf8. PostgreSQL'srepeatreturns "requested length too large" aboveMaxAllocSize, 1 GB minus 1 (oracle_compat.c). DuckDB's strings are limited tou32::MAXbytes (MAX_STRING_SIZE). - Fallible allocation, such as
try_reserve, so that a refused allocation becomes an error.
Which one should repeat use? Neither guards against an allocation that succeeds under overcommit and fails later when the pages are touched. Both turn this case, where the allocator refuses up front, into an error. #22688 tracks checked size accounting for string builders in general.
Additional context
Found by property-based tests that call each function with generated arguments, including large counts.
Willingness to contribute
I cannot contribute a fix for this bug at this time
- Lenguaje dominante
- Rust
- Estrellas
- 9.6k
- Forks
- 2.6k
- Merge medio
- 4 d 5 h
- PR fusionados (30 d)
- 319
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- 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
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
apache/datafusion#26999 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
apache/datafusion#26998 ·
Los mantenedores suelen responder en 1 día
-
[Bug] atan2 does not normalize -0.0 the way Spark doesPosiblemente ocupada @galaxytemple la tomó hace 3 días. Abiertobug spark
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/datafusion#26333 ·
Los mantenedores suelen responder en 1 día
-
Unparser turns NULL list literals into `[]` and fails on NULL struct/map literalsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug help wanted unparser
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/datafusion#26316 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Struct union type coercion takes field nullability from the wrong field when field order differsQuizá libre de nuevo @med9110 la tomó hace 19 días y no hay ningún pull request abierto. Abiertobug help wanted logical-expr tech debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
apache/datafusion#26296 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/datafusion
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
hydro-project/hydro#3289 ·
Los mantenedores suelen responder en 1 día
-
diagram-bug good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
enhapu-afk/omaspec#4 ·
-
priority: low ☕️ type: bug 🐛
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
bug security
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 4 días