[Bug] format_string with %#e puts the decimal point after the exponent

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

维护者通常 1 天内回复

@vaidik787 已经在做这个了。

开始于 2026年11月27日。

  • #427 来自 @vaidik787 —— 未关闭

评估

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

调研方向

从 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

环境准备

从这里开始

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

apache/datafusion-spark 的其他 Issue

查看 apache/datafusion-spark 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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