Carl-Zhou-CN commented on code in PR #6535:
URL: https://github.com/apache/seatunnel/pull/6535#discussion_r1537493489


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/utils/SchemaUtil.java:
##########
@@ -35,20 +37,39 @@ public static DataType toPaimonType(Column column) {
         return PaimonTypeMapper.INSTANCE.reconvert(column);
     }
 
-    public static Schema toPaimonSchema(TableSchema tableSchema) {
+    public static Schema toPaimonSchema(
+            TableSchema tableSchema, PaimonSinkConfig paimonSinkConfig) {
         Schema.Builder paiSchemaBuilder = Schema.newBuilder();
         for (int i = 0; i < tableSchema.getColumns().size(); i++) {
             Column column = tableSchema.getColumns().get(i);
             paiSchemaBuilder.column(column.getName(), toPaimonType(column));
         }
-        PrimaryKey primaryKey = tableSchema.getPrimaryKey();
-        if (Objects.nonNull(primaryKey) && primaryKey.getColumnNames().size() 
> 0) {
-            paiSchemaBuilder.primaryKey(primaryKey.getColumnNames());
+        List<String> primaryKeys = paimonSinkConfig.getPrimaryKeys();
+        if (primaryKeys.isEmpty() && 
Objects.nonNull(tableSchema.getPrimaryKey())) {
+            primaryKeys = tableSchema.getPrimaryKey().getColumnNames();
+        }
+        if (Objects.nonNull(primaryKeys) && primaryKeys.size() > 0) {

Review Comment:
   It seems impossible to be null



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