Hisoka-X commented on code in PR #9219:
URL: https://github.com/apache/seatunnel/pull/9219#discussion_r2058143527
##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/config/PaimonSinkOptions.java:
##########
@@ -40,6 +40,14 @@ public class PaimonSinkOptions extends PaimonBaseOptions {
.enumType(DataSaveMode.class)
.defaultValue(DataSaveMode.APPEND_DATA)
.withDescription("data_save_mode");
+
+ public static final Option<Boolean> NON_PRIMARY_KEY =
+ Options.key("paimon.table.non-primary-key")
+ .booleanType()
+ .defaultValue(false)
+ .withDescription(
+ "Default comma-separated list of columns that
identify a row in tables (primary key)");
Review Comment:
Please update description.
##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/catalog/PaimonCatalog.java:
##########
@@ -271,6 +273,20 @@ private CatalogTable toCatalogTable(
});
List<String> partitionKeys = schema.partitionKeys();
+ List<String> primaryKyes = schema.primaryKeys();
+ if (!primaryKyes.isEmpty()) {
+ builder.primaryKey(PrimaryKey.of("pk", primaryKyes));
+ List<ConstraintKey.ConstraintKeyColumn> constraintKeyColumns =
+ primaryKyes.stream()
+ .map(
+ pk ->
+ new
ConstraintKey.ConstraintKeyColumn(
+ pk,
ConstraintKey.ColumnSortType.ASC))
+ .collect(Collectors.toList());
+ builder.constraintKey(
+ ConstraintKey.of(
+ ConstraintKey.ConstraintType.UNIQUE_KEY, "uk",
constraintKeyColumns));
Review Comment:
I think if a field is a primary key, it must be unique. So do not put it
into constraintKey.
--
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]