fatmanverse opened a new pull request, #12801:
URL: https://github.com/apache/seatunnel/pull/12801
Fixes #12797
### Purpose of this pull request
`XmlWriter#convertToXmlString` wrote DATE, TIME and TIMESTAMP with
`toString()` and ignored `date_format`, `time_format` and `datetime_format`.
`LocalDateTime#toString()` drops zero seconds, so a single file mixed
`2026-01-02T10:13:45` and `2026-01-02T10:13`, and the XML source could not read
it back with any `datetime_format`.
The writer now formats these types with `DateUtils` / `TimeUtils` /
`DateTimeUtils` and the formats from `FileSinkConfig`, the same way
`ExcelGenerator` and the text/CSV serializer do.
Impact checked:
- `BaseFileSinkConfig` reads the three formats with `ReadonlyConfig#get`,
which returns the option default, so they are never null. This covers every
file sink and the Hive sink, which builds a `FileSinkConfig` the same way.
- Nested ROW fields go through the same method and are formatted too.
- `TIMESTAMP_TZ` was not handled by the XML writer before this change and
still is not.
- The XML e2e cases read pre-built fixture files that already use
`yyyy-MM-dd HH:mm:ss`, so they are unaffected.
### Does this PR introduce _any_ user-facing change?
Yes. With the default `datetime_format`, XML timestamps are now written as
`yyyy-MM-dd HH:mm:ss` instead of the ISO `toString()` form, and fractional
seconds are dropped, as for CSV and text. This is documented in
`incompatible-changes.md` (en/zh) with how to keep an ISO layout or
milliseconds (`YYYY_MM_DD_HH_MM_SS_ISO8601` /
`YYYY_MM_DD_HH_MM_SS_SSS_ISO8601`).
### How was this patch tested?
- Added `XmlWriterTest`: zero seconds with the default formats, custom
date/time/datetime formats, and attribute mode.
- `./mvnw -pl seatunnel-connectors-v2/connector-file/connector-file-base
test` on JDK 17: all tests pass.
- On a deployed Zeta cluster, a 3000-row round trip MySQL -> LocalFile XML
-> LocalFile XML source -> MySQL failed at the read step before this change.
After it, the job succeeds, every timestamp has seconds, and all date/timestamp
columns match the source.
### Check list
* [ ] If any new Jar binary package adding in your PR, please add License
Notice according
[New License
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
* [x] If necessary, please update the documentation to describe the new
feature. https://github.com/apache/seatunnel/tree/dev/docs
* [x] If necessary, please update `incompatible-changes.md` to describe the
incompatibility caused by this 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]