LeonYoah commented on code in PR #11746:
URL: https://github.com/apache/seatunnel/pull/11746#discussion_r3800484571


##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/source/ChunkSplitter.java:
##########
@@ -356,7 +354,35 @@ protected Optional<SeaTunnelRowType> 
findSplitKey(JdbcSourceTable table) {
 
         PrimaryKey pk = schema.getPrimaryKey();
         if (pk != null) {
-            for (String pkField : pk.getColumnNames()) {
+            List<String> pkColumnNames = pk.getColumnNames();
+            // Composite primary key: use all key columns (tuple-ordered 
split). Only the dynamic
+            // splitter supports multi-column boundaries, and only for 
dialects whose composite-PK
+            // path is validated by an official E2E (see 
JdbcDialect.supportCompositeKeySplit(),
+            // default false); unvalidated dialects fall back to the 
single-column behavior below.
+            // All key columns must also be splittable (Comparable) types - a 
composite PK
+            // containing e.g. BINARY/VARBINARY would otherwise fail 
compareArrays with a
+            // ClassCastException, so such keys also fall back to the 
single-column path.
+            if (pkColumnNames.size() > 1
+                    && config.isUseDynamicSplitter()
+                    && jdbcDialect.supportCompositeKeySplit()) {
+                List<Column> pkColumns = new ArrayList<>();
+                for (String pkField : pkColumnNames) {
+                    Column column = columnMap.get(pkField);
+                    if (column != null && isSupportSplitColumn(column)) {

Review Comment:
   Many types are supported here, but the e2e you gave only considers numerical 
types and needs to complete the boundaries.



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