SEPURI-SAI-KRISHNA opened a new pull request, #13391:
URL: https://github.com/apache/seatunnel/pull/13391
Yes, glad to contribute to Apache SeaTunnel.
### Purpose of this pull request
Closes #13388. Follow-up to #13188 and #13190, as promised there.
Outside CDC mode, `DatabendSinkWriter.processRow` passes each value to
`PreparedStatement.setObject`. A `TIMESTAMP` value is a
`java.time.LocalDateTime`, which databend-jdbc 0.3.7 rejects with `Unsupported
object type: java.time.LocalDateTime`, so a job with a `TIMESTAMP` column fails
at the first row. #13190 fixed the same error for `LocalTime` only.
The driver's `setTimestamp` is no alternative: it formats the value through
`java.util.Date.getTime()` and keeps only milliseconds.
Change, in `DatabendSinkWriter.processRow`: a `LocalDateTime` is written
with `setString` as `uuuu-MM-dd HH:mm:ss.SSSSSS`. Databend keeps a `TIMESTAMP`
to the microsecond, so nothing is lost; nanoseconds are cut to microseconds.
Every other value is still passed to `setObject` as before, and CDC mode does
not change (it writes rows as JSON text).
The sink docs already list `TIMESTAMP` as `TIMESTAMP`; this makes that
mapping work.
### Does this PR introduce _any_ user-facing change?
Yes. A Databend sink job with a `TIMESTAMP` column now writes its rows
instead of failing outside CDC mode. No option, default, API or table format
changes.
### How was this patch tested?
- `DatabendSinkWriterTest#testProcessRowWritesTimestampAsText`: a whole
hour, microseconds and nanoseconds are each written as text with microseconds,
`setObject` never gets a `LocalDateTime`, and a `LocalDate` is still passed as
is. It fails with the `DatabendSinkWriter` of dev.
- `DatabendIT#testFakeTimestampToDatabend` (new
`fake_timestamp_to_databend.conf`): FakeSource writes three `TIMESTAMP` rows to
a table the sink creates, and each row is matched against an exact timestamp.
Row 2 must also differ from its millisecond value. Run locally on Zeta:
- dev writer: the job fails with `SQLException: Unsupported object type:
java.time.LocalDateTime` from `DatabendPreparedStatement.setObject`;
- this PR: passes, stored `2024-03-10 10:00:00.000000`, `2024-03-11
10:15:30.123456`, `2024-03-12 10:15:30.123456`;
- this PR with a millisecond pattern: fails, stored `...123000`, so the
check catches a lost microsecond.
- Whole `DatabendIT` on Zeta: 10 tests, 0 failures. Fork CI: run 44896333024
on ac09c3d7c6 is green.
- `./mvnw test -pl seatunnel-connectors-v2/connector-databend` on JDK 17: 26
tests, 0 failures. `spotless:check`, `git diff --check`.
### Check list
* [x] 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)
(no new jar)
* [x] If necessary, please update the documentation to describe the new
feature. https://github.com/apache/seatunnel/tree/dev/docs (not needed: the
sink docs already map `TIMESTAMP` to `TIMESTAMP`)
* [x] If necessary, please update `incompatible-changes.md` to describe the
incompatibility caused by this PR. (not needed)
* [x] If you are contributing the connector code, please check that the
following files are updated:
1. Update
[plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties)
and add new connector information in it (not a new connector)
2. Update the pom file of
[seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
(not a new connector)
3. Add ci label in
[label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
(not a new connector)
4. Add e2e testcase in
[seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
(DatabendIT#testFakeTimestampToDatabend)
5. Update connector
[plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
(not a new connector)
--
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]