wuwenchi commented on code in PR #4561:
URL: https://github.com/apache/iceberg/pull/4561#discussion_r851985358


##########
flink/v1.14/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java:
##########
@@ -400,6 +400,30 @@ void createIcebergTable(ObjectPath tablePath, 
CatalogBaseTable table, boolean ig
     }
   }
 
+  private static void validateTableSchemaAndPartition(CatalogTable ct1, 
CatalogTable ct2) {
+    TableSchema ts1 = ct1.getSchema();
+    TableSchema ts2 = ct2.getSchema();
+    boolean equalsPrimary = false;
+    if (ts1.getPrimaryKey().isPresent() && ts2.getPrimaryKey().isPresent()) {
+      equalsPrimary = 
ts1.getPrimaryKey().get().getType().equals(ts2.getPrimaryKey().get().getType()) 
&&
+              
ts1.getPrimaryKey().get().getColumns().equals(ts2.getPrimaryKey().get().getColumns());
+    } else if (!ts1.getPrimaryKey().isPresent() && 
!ts2.getPrimaryKey().isPresent()) {
+      equalsPrimary = true;
+    }

Review Comment:
   @openinx   
   Primarykey is a `UniqueConstraint` , so if use `boolean equalsPrimary = 
Objects.equals(ts1.getPrimaryKey(), ts2.getPrimaryKey());`, it will call 
`super.equals(o)`. Then
   in `AbstractConstraint` 's equals function, it will compare `name` properity 
which generated by `TableSchema`'s `primaryKey`:
   ```
   public Builder primaryKey(String... columns) {
               return primaryKey(UUID.randomUUID().toString(), columns);
           }
   ```
   So, we should not compare the name attribute, and I only compare the type 
and columns from primarykeys.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to