This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new d8330740e4 [test] Fix the unstable testCloneWithSchemaEvolution (#4932)
d8330740e4 is described below
commit d8330740e4e58ca6386efc6dacf434b18e9fa540
Author: tsreaper <[email protected]>
AuthorDate: Thu Jan 16 19:18:55 2025 +0800
[test] Fix the unstable testCloneWithSchemaEvolution (#4932)
---
.../paimon/flink/clone/PickFilesForCloneOperator.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git
a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/clone/PickFilesForCloneOperator.java
b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/clone/PickFilesForCloneOperator.java
index f58d3acafd..512d48170f 100644
---
a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/clone/PickFilesForCloneOperator.java
+++
b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/clone/PickFilesForCloneOperator.java
@@ -25,6 +25,7 @@ import org.apache.paimon.flink.FlinkCatalogFactory;
import org.apache.paimon.fs.Path;
import org.apache.paimon.options.Options;
import org.apache.paimon.schema.Schema;
+import org.apache.paimon.schema.SchemaManager;
import org.apache.paimon.schema.TableSchema;
import org.apache.paimon.table.FileStoreTable;
import org.apache.paimon.utils.Preconditions;
@@ -85,6 +86,20 @@ public class PickFilesForCloneOperator extends
AbstractStreamOperator<CloneFileI
targetCatalog.createDatabase(targetIdentifier.getDatabaseName(), true);
targetCatalog.createTable(
targetIdentifier,
newSchemaFromTableSchema(sourceTable.schema()), true);
+ FileStoreTable targetTable = (FileStoreTable)
targetCatalog.getTable(targetIdentifier);
+
+ // Make sure that latest schema file of source and target table are
the same,
+ // so latest schema won't be overwritten in `CopyFileOperator` and the
target table can
+ // always be retrieved from catalog.
+ SchemaManager sourceSchemaManager = sourceTable.schemaManager();
+ SchemaManager targetSchemaManager = targetTable.schemaManager();
+ long schemaId = sourceTable.schema().id();
+ targetTable
+ .fileIO()
+ .copyFile(
+ sourceSchemaManager.toSchemaPath(schemaId),
+ targetSchemaManager.toSchemaPath(schemaId),
+ true);
List<CloneFileInfo> result =
toCloneFileInfos(