Deduplicate bucket computation in width_bucket_interval_mdn_exact
维护者通常 1 天内回复
@nightcityblade 已经在做这个了。
开始于 2026年10月14日。
评估
调研方向
从 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 内容生成。
描述
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
0ornum_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
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/datafusion 的其他 Issue
-
bug help wanted unparser
难度 2/5 1-3 小时 新手友好度 72/100
apache/datafusion#26316 · 1 条评论 ·
维护者通常 1 天内回复
-
Use the shared aggr_test_schema in CSV scan tests instead of a local copy可能已有人在做 @med9110 今天认领。 未关闭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 今天认领。 未关闭bug functions good first issue help wanted tech debt
难度 1/5 1 小时以内 新手友好度 92/100
apache/datafusion#26297 · 1 条评论 ·
维护者通常 1 天内回复
-
Struct union type coercion takes field nullability from the wrong field when field order differs可能已有人在做 @med9110 今天认领。 未关闭bug help wanted logical-expr tech debt
难度 2/5 1-3 小时 新手友好度 68/100
apache/datafusion#26296 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
apache/datafusion#26290 ·
维护者通常 1 天内回复
查看 apache/datafusion 的全部 Issue
相似的 Issue
-
RUSTSEC-2026-0348: Brotli certificate decompression can allocate up to 1 GiB before authentication未关闭
难度 2/5 1-3 小时 新手友好度 60/100
-
难度 1/5 1-3 小时 新手友好度 62/100
-
core: Amount::from_str panics on values above 21M BTC instead of returning an error可能已有人在做 @bhuvan-somisetty 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
crate: spate-s3
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复
-
write_iceberg ignores the table's write.parquet.compression-codec property可能已有人在做 @YuangGao 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
Eventual-Inc/Daft#7606 ·
维护者通常 1 天内回复