[Bug] format_string with %#e puts the decimal point after the exponent
维护者通常 1 天内回复
评估
调研方向
从 crates/spark/src/function/string/format_string.rs 中约第 1796 行的 alt_form 分支开始,issue 指出小数点会在指数之后追加。检查 %e 格式化路径以及与 format_string 相关的测试。当 %#.0e 将小数点放在指数之前,并与 Spark 的示例 5.e+00 和 0.e+00 一致时,即为完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
format_string with the # flag on %e puts the decimal point after the exponent. format_string('%#.0e', 5.0) returns 5e+00., where Spark returns 5.e+00.
The alt_form branch appends . to the whole formatted number when it has no decimal point (format_string.rs#L1796). For %e the number already ends in the exponent at that point, so the . lands after it. It should go after the mantissa.
To Reproduce
SELECT format_string('%#.0e', CAST(5.0 AS DOUBLE));
datafusion-spark returns 5e+00..
Expected behavior
As in Spark (Java String.format):
5.e+00
%#.0e of 0.0 gives 0.e+00 in Spark. %#e with the default precision already has a decimal point, so it is not affected.
Spark versions
Checked on PySpark 4.2.0 and 3.5.9, which give the same result.
datafusion-spark version
main at ab9d308
Additional context
Found while reviewing #416, which fixes zero for %e and %g. This bug is separate from that one.
- 主要语言
- Rust
- 星标
- 13
- 派生
- 31
- 平均合并
- 2 天 2 小时
- 30 天内合并 PR
- 96
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/datafusion-spark 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 84/100
apache/datafusion-spark#440 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
apache/datafusion-spark#439 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
apache/datafusion-spark#431 ·
维护者通常 1 天内回复
-
[Bug] width_bucket returns NULL for an infinite value可能已有人在做 @vaidik787 于 5 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
apache/datafusion-spark#424 ·
维护者通常 1 天内回复
-
[Bug] parse_url ignores the key for a part other than QUERY, Spark returns NULL可能已有人在做 @Aryan2210 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 64/100
apache/datafusion-spark#409 · 2 条评论 ·
维护者通常 1 天内回复
查看 apache/datafusion-spark 的全部 Issue
相似的 Issue
-
autofix:working
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 75/100
libracoder/kiri#1138 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
roc-lang/basic-webserver#277 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 82/100
samkerrcode/opengent#113 ·
维护者通常 1 天内回复
-
app bug session
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复