`repeat` on `LargeUtf8` aborts the process on a result size no allocation can satisfy
维护者通常 1 天内回复
@huong8373tt-beep 已经在做这个了。
开始于 2026年11月2日。
评估
调研方向
从 datafusion/functions/src/string/repeat.rs 开始,将近 127-128 行处标量路径中的 LargeUtf8 上限与近 227-228 行处的数组路径进行比较。阅读 test_repeat_string_array_overflow 和复现代码片段,然后选择固定上限或 try_reserve 方案,使两个路径在计数为 1 << 60 时都返回错误。添加一个覆盖标量 LargeUtf8 和数组构建器的回归测试,并运行 repeat 相关测试。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Rust
- 星标
- 9.6k
- 派生
- 2.6k
- 平均合并
- 4 天 5 小时
- 30 天内合并 PR
- 319
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/datafusion 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
apache/datafusion#26999 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
apache/datafusion#26998 ·
维护者通常 1 天内回复
-
[Bug] atan2 does not normalize -0.0 the way Spark does可能已有人在做 @galaxytemple 于 3 天前认领。 未关闭bug spark
难度 2/5 1-3 小时 新手友好度 72/100
apache/datafusion#26333 ·
维护者通常 1 天内回复
-
Unparser turns NULL list literals into `[]` and fails on NULL struct/map literals可能重新可做 关联的 PR 已关闭且未合并。 未关闭bug help wanted unparser
难度 2/5 1-3 小时 新手友好度 72/100
apache/datafusion#26316 · 1 条评论 ·
维护者通常 1 天内回复
-
Struct union type coercion takes field nullability from the wrong field when field order differs可能重新可做 @med9110 于 19 天前认领,目前没有进行中的 PR。 未关闭bug help wanted logical-expr tech debt
难度 2/5 1-3 小时 新手友好度 68/100
apache/datafusion#26296 · 1 条评论 ·
维护者通常 1 天内回复
查看 apache/datafusion 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
GiganticMinecraft/seichi-portal-backend#1651 ·
维护者通常 1 天内回复
-
Android visitors are offered the Linux .deb on cap.so's homepage and download page可能已有人在做 @patrickballard 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
CapSoftware/Cap#3677 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复