hutiefang76 opened a new pull request, #12876:
URL: https://github.com/apache/seatunnel/pull/12876
### Purpose of this pull request
Numeric strings for PostgreSQL `interval` targets lose sub-second precision
or become invalid literals. `"1500000"` currently stores one second; `"1"`,
`"0"`, negative counts and values beyond the nanosecond multiplication range
can produce an empty literal that PostgreSQL rejects.
Format integer microsecond counts as signed whole days plus exact fractional
seconds. This preserves negative values, zero and the full signed-long range
without multiplying into nanoseconds. Days keep each component small enough for
older PostgreSQL versions, which reject large integer microsecond/second
literals. Includes existing unit and PostgreSQL IT regressions plus
English/Chinese documentation.
Fixes #12872. Yes, I am contributing this fix to Apache SeaTunnel.
### Does this PR introduce _any_ user-facing change?
Yes. `1500000` now writes an interval of 1.5 seconds, and zero, negative,
sub-second and large integer counts retain their values. The generated literal
text uses days and fractional seconds; existing nonnumeric interval literals
retain their values. Public APIs, options and target column types are unchanged.
### How was this patch tested?
- Baseline: 25 converter tests with five failures. A real PostgreSQL 17
converter probe found six failures among nine cases, including zero rejected by
the server.
- Fixed `PostgresJdbcRowConverterTest`: **27/27 pass**, no skips.
- Existing `JdbcPostgresIT#testIntervalMicrosecondBindingRoundTrip`: **one
test passes**, no failures/errors/skips, on the project's PostGIS image (actual
PostgreSQL 18). It binds 11 values, including both long endpoints, and compares
exact server-side microseconds without floating-point epoch arithmetic.
- Combined production-class probe for this change and #12873 on PostgreSQL
13 and 17: all nine interval cases pass and cross-database row counts match.
Literal controls also confirm both long endpoints on PostgreSQL 13.
- Spotless and root `./mvnw -q -DskipTests verify` pass. Root verify skips
test execution. JDK 17.0.18; independent full-diff review passed.
- Full JDBC package run: **1,165 tests, one failure, zero errors, six
conditional skips**. The failure is the unchanged source-only-option
completeness test, also reproduced on clean dev and addressed separately in
#12875; no interval regression fails. That separate test correction is not
included here.
```sh
./mvnw -pl seatunnel-connectors-v2/connector-jdbc -am package
./mvnw -pl
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-3
-am \
-DskipUT=true -DskipIT=false \
'-Dit.test=JdbcPostgresIT#testIntervalMicrosecondBindingRoundTrip' \
-Dfailsafe.failIfNoSpecifiedTests=false -DfailIfNoTests=false verify
./mvnw -q -DskipTests verify
```
### Check list
* [ ] New JAR license notice: not applicable; no new dependency.
* [x] English/Chinese JDBC sink documentation updated.
* [ ] Incompatible changes: no option/API change; native interval values are
preserved.
* [x] Existing PostgreSQL IT updated. No new connector registration or
plugin config needed.
<sub>Implemented, tested, independently reviewed and posted with AI
assistance for @hutiefang76.</sub>
--
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]