fatmanverse opened a new issue, #12798:
URL: https://github.com/apache/seatunnel/issues/12798
### Search before asking
- [x] I had searched in the issues and found no similar issues.
### What happened
DECIMAL and DOUBLE values lose precision in an Excel round trip (file sink
`file_format_type = "excel"`, then file source reading the same files).
Write side, `ExcelGenerator#setCellValue`:
```java
case DECIMAL:
cell.setCellValue(Double.parseDouble(value.toString()));
```
A `DECIMAL(20, 4)` value is converted to `double`, so anything beyond about
15-17 significant digits is lost before it reaches the file.
Read side, `ExcelReadStrategy#getCellValue` (POI path for `.xlsx` / `.xls`):
```java
case NUMERIC:
...
return formatter.formatCellValue(cell);
```
`DataFormatter` renders the cell with the "General" style, which keeps only
about 10 significant digits. The source then parses that string, so DOUBLE and
DECIMAL values are truncated even when the file itself holds the full `double`
value. `ExcelCellUtils#convert` also builds decimals through
`BigDecimal.valueOf(Double.parseDouble(...))`.
### How to reproduce (verified on `dev` 42d2aab)
Round trip of 3000 rows: MySQL `DECIMAL(20,4)` / `DOUBLE` -> LocalFile excel
-> LocalFile excel source -> MySQL, compared column by column:
| column | mismatched rows (of 3000) | example (source -> after round trip)
|
|---------|---------------------------|--------------------------------------|
| DOUBLE | 2512 | `10.285714285` -> `10.28571428` |
| DECIMAL | 2241 | `1012345.6699` -> `1012345.6700` |
The same pipeline with csv, text, json, parquet and orc has 0 mismatches.
### Expected behavior
DOUBLE values survive the round trip unchanged, and DECIMAL values keep
their exact value, as with the other file formats.
### SeaTunnel Version
dev (3.0.1-SNAPSHOT, 42d2aab)
### Zeta or Flink or Spark Version
Zeta
### Java or Scala Version
JDK 11
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
--
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]