Ivan-gfan opened a new pull request, #13428:
URL: https://github.com/apache/seatunnel/pull/13428
### Purpose of this pull request
Fixes #13427.
`JdbcDialectLoader#load` creates dialects through
`JdbcDialectFactory#create(compatibleMode, fieldIde, jdbcConnectionConfig)`.
#12792 overrode this method in `PostgresDialectFactory`;
`OpenGaussDialectFactory` extends that factory and only overrides the
two-argument `create`, so since 3.1.0 the loader returns a plain
`PostgresDialect` for `jdbc:opengauss:` URLs. Its upsert uses `ON CONFLICT ...
DO UPDATE`, which openGauss rejects with a syntax error, so a sink with
`primary_keys` fails on its first batch.
`OpenGaussDialectFactory` now overrides the three-argument `create` and
returns `OpenGaussDialect`, passing on `field_ide` and
`numeric_special_value_as_null` the same way `PostgresDialectFactory` does.
`OpenGaussDialect` gets the matching constructor.
### Does this PR introduce _any_ user-facing change?
Yes. openGauss sinks with `primary_keys` work again, using `INSERT ... ON
DUPLICATE KEY UPDATE` as in 2.3.13.
`field_ide` and `numeric_special_value_as_null` keep taking effect for
openGauss, as they do in 3.1.0.
### How was this patch tested?
- `OpenGaussDialectTest#loaderReturnsOpenGaussDialectForOpenGaussUrl`:
`JdbcDialectLoader` returns `OpenGaussDialect` for a `jdbc:opengauss:` URL, and
its upsert uses `ON DUPLICATE KEY UPDATE`.
- `OpenGaussDialectTest#loaderKeepsFieldIdeForOpenGaussDialect`: `field_ide`
is applied to the loaded dialect.
- `JdbcOpenGaussIT#testUpsertWithPrimaryKeys`
(`jdbc_opengauss_source_and_sink_upsert.conf`): the target already holds 10 of
the 100 source keys with a different `varchar_col`; the job writes with
`primary_keys = ["gid"]`. It must finish, leave 100 rows, and every row must
carry the source value.
- Without the change, both unit tests fail with `expected:
<OpenGaussDialect> but was: <PostgresDialect>`, and the E2E job fails with
`ERROR: syntax error at or near "CONFLICT ("`.
- With the change, `OpenGaussDialectTest`, `JdbcDialectLoaderTest` and all
of `JdbcOpenGaussIT` (6 cases, including the existing `testJdbcDb`) pass
locally on Zeta.
### 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 dependency)
* [x] If necessary, please update the documentation to describe the new
feature. https://github.com/apache/seatunnel/tree/dev/docs (not needed)
* [x] If necessary, please update `incompatible-changes.md` to describe the
incompatibility caused by this PR. (not needed)
* [ ] If you are contributing the connector code, please check that the
following files are updated: (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]