JingsongLi commented on code in PR #5506:
URL: https://github.com/apache/paimon/pull/5506#discussion_r2053339304
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/clone/hive/ListHiveFilesFunction.java:
##########
@@ -95,6 +118,71 @@ public void processElement(
}
}
+ private void checkCompatible(Schema sourceSchema, FileStoreTable
existedTable) {
+ Schema existedSchema = existedTable.schema().toSchema();
+
+ // check primary keys
+ if (!existedSchema.primaryKeys().isEmpty()) {
+ throw new IllegalStateException(
+ "Can not clone data to existed paimon table which has
primary keys. Existed paimon table is "
+ + existedTable.name());
+ }
+
+ // check bucket
+ if (existedTable.coreOptions().bucket() != -1) {
+ throw new IllegalStateException(
+ "Can not clone data to existed paimon table which bucket
is not -1. Existed paimon table is "
+ + existedTable.name());
+ }
+
+ // check partition keys
+ List<DataField> sourcePartitionFields =
+ new ArrayList<>(
+ TableSchema.create(0, sourceSchema)
+
.projectedLogicalRowType(sourceSchema.partitionKeys())
+ .getFields());
+
+ List<DataField> existedPartitionFields =
+ new ArrayList<>(
+ existedTable
+ .schema()
+
.projectedLogicalRowType(existedTable.partitionKeys())
+ .getFields());
+
+ if (sourcePartitionFields.size() != existedPartitionFields.size()) {
+ throw new IllegalStateException(
+ "size of source table partition keys not equal existed
paimon table partition keys.");
+ }
+ checkCompatible(sourcePartitionFields, existedPartitionFields);
Review Comment:
For partitions, we can just check `List<String>` names.
--
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]