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

Deduplicate bucket computation in width_bucket_interval_mdn_exact

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

维护者通常 1 天内回复

@nightcityblade 已经在做这个了。

开始于 2026年10月14日。

评估

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

调研方向

从 spark/src/function/math/width_bucket.rs 中的 width_bucket_interval_mdn_exact 开始,其中 "only month" 和 "months equals" 两个分支重复了越界检查、宽度保护和桶的钳制逻辑。比较这两个分支,找出它们的差异,主要是 x、l 和 h 如何投影为 f64。提取一个共享的辅助函数,它接收投影后的值并返回 Option<i64>,然后让两个分支都调用它。完成的标准是两个分支都使用该辅助函数,并且现有的 width_bucket 测试在不作修改的情况下全部通过。

由索引模型根据 Issue 内容生成。

描述

enhancement good first issue help wanted spark tech debt
Is your feature request related to a problem or challenge?

width_bucket_interval_mdn_exact (spark/src/function/math/width_bucket.rs#L300-L431) contains two near-identical blocks, "only month" (about L330-L366) and "months equals" (about L368-L424). Each repeats:

  • the ascending/descending out-of-range checks (bucket 0 or num_buckets + 1),
  • the bucket-width computation with its zero / non-finite null guard,
  • the floor-plus-one bucket clamp.

They differ only in how x, l and h are projected to f64 (months vs. day/nanosecond offset relative to l). Duplicated numeric edge-case handling like this is where a boundary fix ends up in only one copy.

Describe the solution you'd like

Extract fn bucket_from_f64(x: f64, l: f64, h: f64, num_buckets: i64, ascending: bool) -> Option<i64> (returning None for null). Each branch then only computes its projected (x, l, h) and calls it. Optionally move the per-row body into a helper returning Option<i64> so the continue chains disappear. The existing width_bucket tests cover the behaviour.

Describe alternatives you've considered

None.

Additional context

This is small and self-contained, a good first issue. Line references are pinned to commit 0d79252f61bd.

主要语言
Rust
星标
9.4k
派生
2.5k
平均合并
4 天 9 小时
30 天内合并 PR
329

环境准备

在 Codespaces 中打开

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

从这里开始

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

apache/datafusion 的其他 Issue

查看 apache/datafusion 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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