chl-wxp opened a new pull request, #10244:
URL: https://github.com/apache/seatunnel/pull/10244

   ## Fix DECIMAL scientific notation in file sinks
   
   ### Background
   
   When syncing DECIMAL / NUMERIC columns to file-based sinks (e.g. CSV, text),
   SeaTunnel currently relies on `BigDecimal.toString()` to convert values to 
text.
   
   However, during investigation we found that **PostgreSQL JDBC may already 
return
   `BigDecimal` values in canonical exponent form**, depending on the numeric 
value
   itself. For example:
   
   - Very small values:
     - `0.000000000000001` → `1E-15`
   - Zero values with large scale:
     - `numeric(18,15) = 0` → `0E-15`
   
   Since `BigDecimal.toString()` preserves the internal representation, these
   exponent forms are directly written into output files, resulting in 
unexpected
   scientific notation such as `1E-15` and `0E-15`.
   
   This behavior is inherited from JDBC and is **not introduced by SeaTunnel’s
   formatting logic**, but it is generally **undesirable for text-based file 
outputs**.
   
   ---
   
   ### Problem
   
   Using `BigDecimal.toString()` for file sinks causes:
   
   1. Scientific notation (`1E-15`, `0E-15`) to appear in CSV / text files
   2. Poor readability for users
   3. Inconsistent behavior compared with mainstream data systems (Spark, 
Trino, DuckDB)
   4. Potential issues for downstream systems expecting plain decimal values
   
   Adding configuration options for this behavior is not ideal, as this affects
   **default file sink semantics**, where scientific notation should be avoided.
   
   ---
   
   ### Solution
   
   This PR changes the DECIMAL formatting logic for file sinks to:
   
   ```java
   bd.stripTrailingZeros().toPlainString()
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to