Repository navigation
[Fix][Connector-V2][Jdbc] Return the openGauss dialect from the dialect loader again - #13428
Conversation
…ct loader again JdbcDialectLoader creates dialects through the three-argument JdbcDialectFactory#create. PostgresDialectFactory overrides it since 3.1.0, and OpenGaussDialectFactory inherited that override, so jdbc:opengauss: URLs got a plain PostgresDialect. Its upsert uses ON CONFLICT ... DO UPDATE, which openGauss rejects with a syntax error, so sinks with primary_keys failed on the first batch. Override the three-argument create in OpenGaussDialectFactory and return OpenGaussDialect, passing on field_ide and numeric_special_value_as_null.
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for contributing to Apache SeaTunnel! I reviewed the complete current diff and followed its entry points and failure paths. I did not find a source-level merge blocker in the reviewed paths.
What problem does this PR solve?
User pain: a normal openGauss JDBC job selected the PostgreSQL dialect through the loader and generated PostgreSQL upsert SQL. Updating an existing primary key could therefore fail.
Fix: override the three-argument factory method actually called by the loader and pass through identifier casing and numeric conversion policy.
In one sentence: use the openGauss SQL generator when a JDBC job targets openGauss. For example, an existing row (id=1, name=old) can be updated to name=new using the database-specific upsert.
1. Code changes
1.1 Core logic
Complete runtime path:
JdbcSinkFactory.createSink / JdbcSourceFactory.createSource
-> JdbcDialectLoader.load [JdbcDialectLoader.java:75-127]
-> discover factories and select OpenGaussDialectFactory by URL/name
-> create(compatibleMode, fieldIde, connectionConfig) [OpenGaussDialectFactory.java:57-64]
-> OpenGaussDialect(fieldIde, numericSpecialValueAsNull) [OpenGaussDialect.java:32-33]
-> inherited PostgreSQL row conversion + openGauss getUpsertStatement [37-55]
-> existing JDBC buffering/execution/commit and error propagation
Key findings and correctness:
- The normal loader path really calls the three-argument overload, including callers of the four-argument loader (which delegates with null connection config). Previously Java dispatch inherited PostgresDialectFactory.create and returned PostgresDialect.
- The override preserves both fieldIde and numericSpecialValueAsNull; null config still means false. The no-argument constructor is retained, so existing direct construction continues to work.
- URL matching and AutoService registration stay in the openGauss factory. PostgreSQL and its low-compatibility variant retain their own factory behavior.
- This is a precise connector-specific correction. The older two-argument factory overload still has its old behavior; this PR does not newly change that contract.
- The existing openGauss generator is reused, including its existing empty-update fallback. No checkpoint, recovery wire format, or transaction lifecycle is modified.
Before:
// Inherited PostgresDialectFactory.create(...):
return new PostgresDialect(fieldIde, numericSpecialValueAsNull);After:
return new OpenGaussDialect(fieldIde, numericSpecialValueAsNull);1.2 Compatibility
Fully compatible with existing loader/API/configuration contracts: existing constructors remain available, field_ide and numeric-special-value policy are forwarded, and no state format, option name/default, network protocol, or dependency changes. The intended behavior correction selects openGauss upsert SQL instead of PostgreSQL SQL.
1.3 Performance and side effects
One dialect object is constructed at setup as before. No new per-row allocation, buffer, network round trip, lock, retry, or thread is added. JDBC resource/commit ownership is unchanged.
1.4 Errors, logging, and findings
No new source-level blocker found. Exceptions must still reach the existing job failure path; this review does not substitute for current-head CI.
There were no non-author, non-Daniel technical reviews or maintainer merge recommendations in the collected discussion. No duplicate finding is added.
2. Code quality
2.1 Conventions
Reviewed all changed files for license, imports, naming, core-method and state-field comments. No additional convention blocker found.
2.2 Test coverage and stability
Stability rating: Stable. Stable. OpenGaussDialectTest.java:36-52 goes through the real ServiceLoader/loader and checks both concrete dialect and generated SQL, then identifier casing. JdbcOpenGaussIT.java:258-295 seeds colliding keys with stale values, executes a real source-to-sink job, and asserts both exact row count and updated values; resources close with try-with-resources and the target table is dropped in finally. The source fixture at :344-352 supplies the exact varchar values used by the assertion. There is no new sleep, clock assertion, or random port dependency in the added code. CI is still running; this is source analysis of the test, not a claim that the new IT passed. Numeric-special-value propagation is inspected but has no added dedicated regression here.
2.3 Documentation
No new configuration, syntax or default is introduced. This restores the existing openGauss upsert behavior, so no mandatory new docs/en or docs/zh option entry is needed.
3. Architecture
3.1 Change location
The root cause is inherited overload dispatch at OpenGaussDialectFactory, not generic JdbcDialectLoader. Overriding that exact SPI method and forwarding to the openGauss subtype is the smallest safe fix and the best ownership boundary. Changing the shared loader would affect every database with no benefit here.
3.2 Maintainability
Keep the behavior, lifecycle ownership, and failure contract together. The root cause is inherited overload dispatch at OpenGaussDialectFactory, not generic JdbcDialectLoader. Overriding that exact SPI method and forwarding to the openGauss subtype is the smallest safe fix and the best ownership boundary. Changing the shared loader would affect every database with no benefit here.
3.3 Extensibility
Prefer the existing component boundary and tests over unrelated shared abstractions.
3.4 Upgrade impact
Fully compatible with existing loader/API/configuration contracts: existing constructors remain available, field_ide and numeric-special-value policy are forwarded, and no state format, option name/default, network protocol, or dependency changes. The intended behavior correction selects openGauss upsert SQL instead of PostgreSQL SQL.
4. Findings summary
Completeness check: All changed files and affected entry/failure paths were reviewed; configuration/serialization compatibility, test failure capability and stability, documentation/examples, change ownership, and current CI/conflict/review gates are covered above. No unreviewed source scope is claimed complete.
| # | Finding | Location | Severity |
|---|---|---|---|
| - | No new source blocker found | - | - |
5. Merge recommendation
Can merge once the recorded CI and repository gates are satisfied
Blocking items: No source blocker. Current-head CI and write-capable maintainer review remain independent requirements.
Non-blocking suggestions: None beyond the validation limits above.
Overall: the reviewed source path is coherent; no runtime acceptance is claimed beyond the actual CI result. Daniel has READ permission, so this COMMENT cannot dismiss historical requested changes or satisfy a write-capable maintainer approval gate.
CI and repository state: Signal pull request update: SUCCESS; Build: IN_PROGRESS; Build: in_progress. GitHub reports BLOCKED / REVIEW_REQUIRED.
Verification: Reviewed all changed files and the referenced call sites at 9c822a5163311e47a61b031c7144498eb70fffc9 against merge base f34fa479c99bad36958867b456f0dd1210e833a9. git diff --check passed. I did not build, run tests, or execute SeaTunnel locally.
Review time: 2026-11-24T06:35:41.158636-05:00
Local evidence: git fetch obtained head 9c822a5163311e47a61b031c7144498eb70fffc9; git merge-base returned f34fa479c99bad36958867b456f0dd1210e833a9; git diff --stat reports 5 files changed, 147 insertions(+). git show and source searches were used for the entry points above. No local build, unit test, E2E, Docker run or service startup was executed.
…alue_as_null Load the dialect for an openGauss URL with numeric_special_value_as_null enabled and read a NUMERIC NaN through its row converter: the value is read as null. With the option off the same read still fails, so the test shows that the loader passes the option through to OpenGaussDialect.
DanielLeens
left a comment
There was a problem hiding this comment.
Thank you for the update and for contributing to Apache SeaTunnel! I reviewed the entire current diff again, including the entry points and failure/recovery paths, rather than only the latest commit. The added loader/quoting/NaN tests address the option-propagation evidence gap. I found no source-level blocker in this head.
What problem does this PR solve?
User pain: A normal openGauss JDBC configuration can accidentally obtain a PostgreSQL dialect and generate PostgreSQL ON CONFLICT SQL.
Approach: Override the three-argument factory overload used by JdbcDialectLoader and preserve field casing plus numeric-special-value handling.
Example and summary: Updating an existing primary key now reaches openGauss ON DUPLICATE KEY UPDATE; it no longer fails on PostgreSQL-only upsert syntax.
1. Code changes
1.1 Core logic
Complete runtime path:
Jdbc source/sink preparation -> JdbcDialectLoader.load:127
-> selected OpenGaussDialectFactory.create(mode,fieldIde,connectionConfig)
-> new OpenGaussDialect(fieldIde,numericSpecialValueAsNull)
-> inherited PostgreSQL row conversion/quoting with preserved options
-> OpenGaussDialect.getUpsertStatement override -> openGauss upsert SQL
-> JDBC writer execution / commit and normal resource cleanup
Key findings and correctness:
- The normal loader invokes the three-argument factory method, so overriding only the older overload was insufficient; the base PostgresDialectFactory returned a PostgresDialect. This is a precise reachable correction.
- Both no-argument construction and the old API remain. The new overload passes fieldIde and the null-safe option boolean into the parent constructor, preserving the row converter's opt-in NaN handling.
- Existing openGauss SQL generation is reused rather than reimplemented; no connector-specific behavior leaks into the shared loader.
- The new tests exercise the actual loader, uppercase quoting, NaN opt-in and default rejection; the existing E2E seeds stale values under duplicate keys and checks all final values/counts. The new head strengthens evidence without widening production scope.
Before:
public class OpenGaussDialect extends PostgresDialect {
@Override
public Optional<String> getUpsertStatement(
String database, String tableName, String[] fieldNames, String[] pkNames) {
After:
public class OpenGaussDialect extends PostgresDialect {
public OpenGaussDialect() {
super();
}
public OpenGaussDialect(String fieldIde, boolean numericSpecialValueAsNull) {
super(fieldIde, numericSpecialValueAsNull);
}
@Override
public Optional<String> getUpsertStatement(
String database, String tableName, String[] fieldNames, String[] pkNames) {
1.2 Compatibility
Fully compatible at the existing configuration and row-contract level; no option rename, protocol change, default change, or new dependency is introduced.
1.3 Performance and side effects
The change remains in the affected component. It introduces no per-row global lock, unbounded data buffer, or new network dependency; exceptional-path costs and resource ownership are discussed above.
1.4 Errors, logging, and findings
No new source-level blocker found. Exceptions must still reach the existing job failure path; this review does not substitute for current-head CI.
Community input: no independent technical finding or maintainer approval/change request was present in the collected discussion.
2. Code quality
2.1 Conventions
Reviewed all changed files for license, imports, naming, core-method and state-field comments. No additional convention blocker found.
2.2 Test coverage and stability
Stability rating: Stable. Stable: OpenGaussDialectTest uses local mocks and the actual loader, not a live localhost connection. numericNaNResultSet models the driver numeric exception; the enabled path produces null and the default path throws. JdbcOpenGaussIT.testUpsertWithPrimaryKeys uses a separate target, completes the job before exact count/value checks and drops it in finally. Container/authentication failures remain environmental prerequisites rather than passing results. No sleeps, clock-dependent expected values or new shared static mutation were added. New-head CI must finish; the previous head's results are not transferred.
2.3 Documentation
No new option/default is introduced. Existing openGauss and numeric-special-value documentation remains applicable; the change restores the intended dialect selection, so no new bilingual option entry is required.
3. Architecture
3.1 Change location
The affected component owns this behavior. Keep the smallest complete correction there; a wider engine or connector redesign is not justified by this diff.
3.2 Maintainability
Keep the behavior, lifecycle ownership, and failure contract together. The affected component owns this behavior. Keep the smallest complete correction there; a wider engine or connector redesign is not justified by this diff.
3.3 Extensibility
Prefer the existing component boundary and tests over unrelated shared abstractions.
3.4 Upgrade impact
Fully compatible at the existing configuration and row-contract level; no option rename, protocol change, default change, or new dependency is introduced.
4. Findings summary
Completeness check: All changed files and affected entry/failure paths were reviewed; configuration/serialization compatibility, test failure capability and stability, documentation/examples, change ownership, and current CI/conflict/review gates are covered above. No unreviewed source scope is claimed complete.
| # | Finding | Location | Severity |
|---|---|---|---|
| - | No new source blocker found | - | - |
5. Merge recommendation
Can merge once the recorded CI and repository gates are satisfied
Blocking items: No source blocker. Current-head CI and write-capable maintainer review remain independent requirements.
Non-blocking suggestions: None beyond the validation limits above.
Overall: the reviewed source path is coherent; no runtime acceptance is claimed beyond the actual CI result. Daniel has READ permission, so this COMMENT cannot dismiss historical requested changes or satisfy a write-capable maintainer approval gate.
CI and repository state: Signal pull request update: SUCCESS; Build: IN_PROGRESS; Build: queued. GitHub reports BLOCKED / REVIEW_REQUIRED.
Verification: Reviewed all changed files and the referenced call sites at e95929702cf218a681aaccaee5862da261426d40 against merge base f34fa479c99bad36958867b456f0dd1210e833a9. git diff --check passed. I did not build, run tests, or execute SeaTunnel locally.
Review time: 2026-11-24T07:39:23.415417-05:00
Local evidence: git fetch obtained head e95929702cf218a681aaccaee5862da261426d40; git merge-base returned f34fa479c99bad36958867b456f0dd1210e833a9; git diff --stat reports 5 files changed, 209 insertions(+). git show and source searches were used for the entry points above. No local build, unit test, E2E, Docker run or service startup was executed.
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for keeping this moving! The CI facts cited in my previous review have changed. The previous remaining blocker was CI; the current-head Build now reports SUCCESS, so I am changing my technical review to APPROVED. The earlier pending/failure/cancelled guidance is superseded. This is a gate-only follow-up on unchanged head e95929702cf218a681aaccaee5862da261426d40; it adds no new source finding and does not claim a new full source review.
5. Merge recommendation
Conclusion: Can merge once repository gates are satisfied
Blocking items: No remaining source blocker in my previous full review. The previously cited CI blocker has cleared. GitHub currently reports BLOCKED / REVIEW_REQUIRED. Effective write-capable maintainer approval, any required historical-review dismissal, and merge-queue policy remain separate.
Non-blocking suggestions: Those in the previous full review remain unchanged. No drift-only sync request is being added.
Overall, this updates the validation gate only. No alternative implementation or unrelated dependency patch is needed for this gate transition. Daniel has READ permission; this technical APPROVED event does not substitute for write-level approval or dismiss historical changes requested. The sidebar rendering and its cause have not been visually established. No local build, test or runtime was executed.
davidzollo
left a comment
There was a problem hiding this comment.
+1
LGTM
Thanks for your contribution!
Please join our Apache SeaTunnel #contributors channel on Slack for technical discussions and collaboration: https://s.apache.org/seatunnel-slack
Purpose of this pull request
Fixes #13427.
JdbcDialectLoader#loadcreates dialects throughJdbcDialectFactory#create(compatibleMode, fieldIde, jdbcConnectionConfig). #12792 overrode this method inPostgresDialectFactory;OpenGaussDialectFactoryextends that factory and only overrides the two-argumentcreate, so since 3.1.0 the loader returns a plainPostgresDialectforjdbc:opengauss:URLs. Its upsert usesON CONFLICT ... DO UPDATE, which openGauss rejects with a syntax error, so a sink withprimary_keysfails on its first batch.OpenGaussDialectFactorynow overrides the three-argumentcreateand returnsOpenGaussDialect, passing onfield_ideandnumeric_special_value_as_nullthe same wayPostgresDialectFactorydoes.OpenGaussDialectgets the matching constructor.Does this PR introduce any user-facing change?
Yes. openGauss sinks with
primary_keyswork again, usingINSERT ... ON DUPLICATE KEY UPDATEas in 2.3.13.field_ideandnumeric_special_value_as_nullkeep taking effect for openGauss, as they do in 3.1.0.How was this patch tested?
OpenGaussDialectTest#loaderReturnsOpenGaussDialectForOpenGaussUrl:JdbcDialectLoaderreturnsOpenGaussDialectfor ajdbc:opengauss:URL, and its upsert usesON DUPLICATE KEY UPDATE.OpenGaussDialectTest#loaderKeepsFieldIdeForOpenGaussDialect:field_ideis 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 differentvarchar_col; the job writes withprimary_keys = ["gid"]. It must finish, leave 100 rows, and every row must carry the source value.expected: <OpenGaussDialect> but was: <PostgresDialect>, and the E2E job fails withERROR: syntax error at or near "CONFLICT (".OpenGaussDialectTest,JdbcDialectLoaderTestand all ofJdbcOpenGaussIT(6 cases, including the existingtestJdbcDb) pass locally on Zeta.Check list
New License Guide (no new dependency)
incompatible-changes.mdto describe the incompatibility caused by this PR. (not needed)