JacobZheng0927 opened a new pull request, #11893:
URL: https://github.com/apache/seatunnel/pull/11893

   ### Purpose of this pull request
   
   `JdbcSink.createWriter()` assumes that every non-null primary-key object has 
at least one column name. Schema metadata can instead contain an empty or null 
primary-key column list, causing sink writer creation to fail before any JDBC 
statement is executed.
   
   This patch centralizes primary-key index lookup and treats absent, empty, 
null, or unknown primary-key columns as no primary-key index.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, as a bug fix. JDBC sink writer creation no longer fails when upstream 
schema metadata reports a primary key without usable column names.
   
   ### How was this patch tested?
   
   Added `JdbcSinkTest` coverage for empty and null primary-key column lists, 
plus the normal first-primary-key-column lookup.
   
   Ran focused connector-JDBC unit tests locally with JDK 8:
   
   ```shell
   ./mvnw -pl seatunnel-connectors-v2/connector-jdbc -am \
     -Dtest=JdbcSinkTest \
     -DfailIfNoTests=false test
   ```
   
   Result: 3 tests run, 0 failures, 0 errors.
   
   A database E2E is not required because the failure occurs while deriving the 
writer schema before JDBC statements are created.
   
   ### Check list
   
   * [x] No new Jar binary package is added.
   * [x] Documentation and incompatible-change updates are not required for 
this bug fix.
   * [x] No new connector, plugin mapping, distribution dependency, or 
connector configuration is required.
   


-- 
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]

Reply via email to