Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

array_min / array_max fail on a zero-row batch for non-primitive element types

未关闭 适合新手
#26,072 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@linuxpi 已经在做这个了。

开始于 2026年10月6日。

  • #26073 来自 @linuxpi —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
databases

调研方向

从 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

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/datafusion 的其他 Issue

查看 apache/datafusion 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。