hdygxsj commented on code in PR #6362:
URL: https://github.com/apache/gravitino/pull/6362#discussion_r1950845159


##########
flink-connector/flink/src/main/java/org/apache/gravitino/flink/connector/catalog/BaseCatalog.java:
##########
@@ -554,28 +554,31 @@ protected CatalogBaseTable toFlinkTable(Table table) {
           .column(column.name(), column.nullable() ? flinkType.nullable() : 
flinkType.notNull())
           .withComment(column.comment());
     }
-    handleFlinkPrimaryKey(table, builder);
+    Optional<List<String>> flinkPrimaryKey = getFlinkPrimaryKey(table);
+    flinkPrimaryKey.ifPresent(builder::primaryKey);
     Map<String, String> flinkTableProperties =
         propertiesConverter.toFlinkTableProperties(table.properties());
     List<String> partitionKeys = 
partitionConverter.toFlinkPartitionKeys(table.partitioning());
     return CatalogTable.of(builder.build(), table.comment(), partitionKeys, 
flinkTableProperties);
   }
 
-  private static void handleFlinkPrimaryKey(
-      Table table, org.apache.flink.table.api.Schema.Builder builder) {
+  private static Optional<List<String>> getFlinkPrimaryKey(Table table) {
     List<Index> primaryKeyList =
         Arrays.stream(table.index())
             .filter(index -> index.type() == Index.IndexType.PRIMARY_KEY)
             .collect(Collectors.toList());
     if (primaryKeyList.isEmpty()) {
-      return;
+      return Optional.empty();
     }
     Preconditions.checkArgument(
         primaryKeyList.size() == 1, "More than one primary key is not 
supported.");
-    builder.primaryKey(
+    List<String> primaryKeyFieldList =
         Arrays.stream(primaryKeyList.get(0).fieldNames())
             .map(fieldNames -> fieldNames[0])

Review Comment:
   done



-- 
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: commits-unsubscr...@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to