hutiefang76 opened a new issue, #12872:
URL: https://github.com/apache/seatunnel/issues/12872
### Search before asking
- [x] Searched open/closed issues and PRs and inspected adjacent fixes; no
same-purpose fix found.
### What happened
Numeric interval values in the PostgreSQL row converter do not round-trip as
microseconds. For example, a string field with `sourceType="interval"` and
value `"1500000"` is bound as `1 seconds`, so PostgreSQL stores only 1,000,000
microseconds. `"1"`, `"-1"`, `"-1500000"`, `"0"`, and `"9223372036854776"`
become empty interval literals and are rejected by PostgreSQL.
Confirmed by calling the current `PostgresJdbcRowConverter.toExternal()`
with a real prepared statement into a temporary PostgreSQL 17 interval table.
Exact server-side read-back shows six failures among nine cases; whole-second,
day-plus-time, and nonnumeric interval-literal controls pass. The existing
converter unit suite reports 25 tests with five failures, no errors/skips
(pgjdbc's local interval parser treats an empty literal as zero, which is why
the real-server zero case adds a failure).
`microsecondsToIntervalFormatVal()` multiplies a long by 1000, creates a
Duration, and emits only positive whole components. That drops fractional
microseconds, loses negative values and zero, and overflows for large
microsecond counts.
I will format signed microseconds without the nanosecond multiplication,
preserving the exact fractional part and large values. The format must also
work on older PostgreSQL: PostgreSQL 13 rejects a large integer `microseconds`
literal, while signed days plus remaining fractional seconds round-trip
exactly. I will extend the existing converter suite and `JdbcPostgresIT`, run
the affected regressions and actual PostgreSQL checks, and document the
behavior in English and Chinese. Public APIs/options and nonnumeric interval
literals keep their behavior.
### SeaTunnel Version
Dev at `e2957d27afa29d4de4324cf642450757d865b902`.
### SeaTunnel Config
Direct public JDBC converter/catalog API reproduction, no engine job.
PostgreSQL 17 in an isolated local test container; numeric-literal
compatibility also checked with PostgreSQL 13.
### Running Command
```sh
./mvnw -pl seatunnel-connectors-v2/connector-jdbc -am \
-Dtest=PostgresJdbcRowConverterTest
-Dsurefire.failIfNoSpecifiedTests=false \
-DfailIfNoTests=false package
```
Actual database validation uses the compiled current production classes and
the public APIs described above.
### Error Exception
```text
25 tests, 5 failures, 0 errors/skips
```
### Java or Scala Version
JDK 17.0.18, macOS ARM64.
### Are you willing to submit PR?
- [x] Yes, I am contributing this fix to Apache SeaTunnel.
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct.
<sub>Reproduction and report prepared and posted by an AI assistant 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]