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

Aperta Adatta ai principianti
#423 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@vaidik787 ci sta già lavorando.

Dal 27/11/2026.

  • #427 di @vaidik787 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
80/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
backend

Direzione di ricerca

Inizia in crates/spark/src/function/string/format_string.rs, nel ramo alt_form intorno alla riga 1796, dove l’issue segnala che il separatore decimale viene aggiunto dopo l’esponente. Controlla il percorso di formattazione %e e i test correlati a format_string. Il lavoro è completato quando %#.0e colloca il separatore decimale prima dell’esponente, come negli esempi 5.e+00 e 0.e+00 di Spark.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Rust
Stelle
13
Fork
31
Merge medio
2g 2h
PR unite (30g)
96

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/datafusion-spark

Tutte le issue di apache/datafusion-spark

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.