[Fix][Connector-jdbc] Fix postgresql sink trying to update unique key (#9293)#9298
Conversation
7c8020e to
110157d
Compare
There was a problem hiding this comment.
Pull Request Overview
This pull request fixes an issue in the PostgreSQL JDBC connector where primary key columns were unnecessarily updated during upsert operations. The diff updates the dialect logic to conditionally generate either a DO NOTHING or a DO UPDATE clause based on the provided key fields and adds accompanying tests as well as an entry in the release note.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/psql/PostgresDialectTest.java | Added unit tests verifying correct upsert statement generation |
| seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/psql/PostgresDialect.java | Adjusted upsert statement logic to filter out primary key fields during update clause construction |
| release-note.md | Updated release note to reflect the fix |
Comments suppressed due to low confidence (2)
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/psql/PostgresDialectTest.java:32
- [nitpick] Consider renaming 'doUpdatekeyFields' to 'doUpdateKeyFields' to follow standard camelCase naming conventions.
final String[] doUpdatekeyFields = {"id"};
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/psql/PostgresDialectTest.java:33
- [nitpick] Consider renaming 'doNothingkeyFields' to 'doNothingKeyFields' to follow standard camelCase naming conventions.
final String[] doNothingkeyFields = {"id", "type", "role_name", "description", "create_time", "update_time"};
110157d to
dd5b6dc
Compare
| "id", "type", "role_name", "description", "create_time", "update_time" | ||
| }; | ||
| final String[] doUpdateKeyFields = {"id"}; | ||
| final String[] doNothingKeyFields = { |
There was a problem hiding this comment.
changed to camelCase style.
|
Thanks @papadave66 ! LGTM. Please open ci on your fork repository. https://github.com/apache/seatunnel/pull/9298/checks?check_run_id=41943176159 |
185c986 to
635f713
Compare
Oh I just enabled the flow. Please tell me if i am doing correctly. |
|
Please resolve the conflicts. |
635f713 to
e7314ad
Compare
|
wating ci passes. |
e7314ad to
996299c
Compare
Purpose of this pull request
close #9293
The JDBC connector of postgresql trying to update primary key colums which is not needed. Then I do some research on apache/flink-connector-jdbc#155 . They fix this month ago. So I think fix in here should be a good idea :)
And I use [fix] instead of [bug] because I am not sure if it is a bug or a feature.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Unit test:
org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.psql.PostgresDialectTestCheck list
New License Guide
release-note.