array_min / array_max fail on a zero-row batch for non-primitive element types
维护者通常 1 天内回复
评估
调研方向
从 datafusion/functions-nested/src/min_max.rs 中的 array_min_max_helper 开始,追踪非基本元素类型的 fallback。为零行 List<Utf8> 输入添加测试覆盖,并验证该函数在没有错误的情况下返回零行;与现有的基本类型行为进行比较。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
array_min / array_max on a zero-row List<Utf8> (or any non-primitive element type) fails:
Execution error: Empty iterator passed to ScalarValue::iter_to_array
A zero-row List<Int64> works. array_min_max_helper (datafusion/functions-nested/src/min_max.rs) only has a fast path for primitive types; the fallback builds a Vec<ScalarValue> and calls ScalarValue::iter_to_array, which rejects an empty iterator.
Zero-row batches do reach these functions in practice: ProjectionExec and TopK evaluate expressions on every batch, so ORDER BY array_min(tags) LIMIT n fails whenever an input emits an empty batch.
To Reproduce
use std::sync::Arc;
use datafusion::arrow::array::{ArrayRef, ListBuilder, StringBuilder};
use datafusion::arrow::record_batch::RecordBatch;
use datafusion::prelude::SessionContext;
#[tokio::main]
async fn main() -> datafusion::error::Result<()> {
let ctx = SessionContext::new();
let tags: ArrayRef = Arc::new(ListBuilder::new(StringBuilder::new()).finish());
ctx.register_batch("t", RecordBatch::try_from_iter(vec![("tags", tags)])?)?;
ctx.sql("SELECT array_min(tags) FROM t").await?.show().await?; // error
Ok(())
}
Seen on 54.0.0; the code is unchanged on main.
Expected behavior
Zero rows, the same as for primitive element types.
Additional context
Found in OpenSearch's DataFusion backend when sorting on multi-valued keyword fields with an empty shard. Proposed fix: return new_empty_array(&array.value_type()) for an empty input before the fallback. PR to follow.
- 主要语言
- Rust
- 星标
- 9.5k
- 派生
- 2.5k
- 平均合并
- 4 天 19 小时
- 30 天内合并 PR
- 342
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/datafusion 的其他 Issue
-
[Bug] atan2 does not normalize -0.0 the way Spark does可能已有人在做 @spicysharkco 于 1 天前认领。 未关闭bug spark
难度 2/5 1-3 小时 新手友好度 72/100
apache/datafusion#26333 ·
维护者通常 1 天内回复
-
bug help wanted unparser
难度 2/5 1-3 小时 新手友好度 72/100
apache/datafusion#26316 · 1 条评论 ·
维护者通常 1 天内回复
-
Deduplicate bucket computation in width_bucket_interval_mdn_exact可能已有人在做 @nightcityblade 于 3 天前认领。 未关闭enhancement good first issue help wanted spark tech debt
难度 2/5 1-3 小时 新手友好度 85/100
apache/datafusion#26307 · 3 条评论 ·
维护者通常 1 天内回复
-
Use the shared aggr_test_schema in CSV scan tests instead of a local copy可能已有人在做 @med9110 于 3 天前认领。 未关闭core enhancement good first issue help wanted tech debt
难度 2/5 1-3 小时 新手友好度 85/100
apache/datafusion#26306 · 2 条评论 ·
维护者通常 1 天内回复
-
gcd benchmarks pass number_rows: 0 for 100k-row inputs可能已有人在做 @med9110 于 3 天前认领。 未关闭bug functions good first issue help wanted tech debt
难度 1/5 1 小时以内 新手友好度 92/100
apache/datafusion#26297 · 1 条评论 ·
维护者通常 1 天内回复
查看 apache/datafusion 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
pop-os/cosmic-comp#2956 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
area:release criticality:p3 documentation
难度 2/5 1-3 小时 新手友好度 68/100
registrystack/registry-stack#2085 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
libp2p/rust-libp2p#6694 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
EmbarkStudios/cargo-deny#910 ·