This is an automated email from the ASF dual-hosted git repository.
JingsongLi 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 4d0a651567 [hive] Avoid treating empty partitioned tables as
unpartitioned during migration (#8100)
4d0a651567 is described below
commit 4d0a6515670767c6db22823201e33d33a19b7b56
Author: huangxiaoping <[email protected]>
AuthorDate: Wed Jun 3 21:45:37 2026 +0800
[hive] Avoid treating empty partitioned tables as unpartitioned during
migration (#8100)
---
.../java/org/apache/paimon/hive/migrate/HiveMigrator.java | 14 ++++++++------
.../spark/procedure/MigrateTableProcedureTest.scala | 15 +++++++++++++++
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/migrate/HiveMigrator.java
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/migrate/HiveMigrator.java
index e25a61e16f..830a01f978 100644
---
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/migrate/HiveMigrator.java
+++
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/migrate/HiveMigrator.java
@@ -165,20 +165,22 @@ public class HiveMigrator implements Migrator {
FileStoreTable paimonTable = (FileStoreTable)
hiveCatalog.getTable(identifier);
checkPaimonTable(paimonTable);
- List<Partition> partitions =
- client.listPartitions(sourceDatabase, sourceTable,
Short.MAX_VALUE);
checkCompatible(sourceHiveTable, paimonTable);
List<MigrateTask> tasks = new ArrayList<>();
Map<Path, Path> rollBack = new ConcurrentHashMap<>();
- if (partitions.isEmpty()) {
+ if (sourceHiveTable.getPartitionKeys().isEmpty()) {
tasks.add(
importUnPartitionedTableTask(
fileIO, sourceHiveTable, paimonTable,
rollBack));
} else {
- tasks.addAll(
- importPartitionedTableTask(
- fileIO, partitions, sourceHiveTable,
paimonTable, rollBack));
+ List<Partition> partitions =
+ client.listPartitions(sourceDatabase, sourceTable,
Short.MAX_VALUE);
+ if (!partitions.isEmpty()) {
+ tasks.addAll(
+ importPartitionedTableTask(
+ fileIO, partitions, sourceHiveTable,
paimonTable, rollBack));
+ }
}
List<Future<CommitMessage>> futures =
diff --git
a/paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/procedure/MigrateTableProcedureTest.scala
b/paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/procedure/MigrateTableProcedureTest.scala
index 8befd3082c..dcd832ba0d 100644
---
a/paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/procedure/MigrateTableProcedureTest.scala
+++
b/paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/procedure/MigrateTableProcedureTest.scala
@@ -153,6 +153,21 @@ class MigrateTableProcedureTest extends PaimonHiveTestBase
{
}
})
+ test("Paimon migrate table procedure: migrate empty partitioned table") {
+ withTable(s"hive_tbl$random") {
+ spark.sql(s"""
+ |CREATE TABLE hive_tbl$random (id STRING, name STRING, pt
STRING)
+ |USING parquet
+ |PARTITIONED BY (pt)
+ |""".stripMargin)
+
+ spark.sql(
+ s"CALL sys.migrate_table(source_type => 'hive', table =>
'$hiveDbName.hive_tbl$random', options => 'file.format=parquet')")
+
+ checkAnswer(spark.sql(s"SELECT * FROM hive_tbl$random"), Nil)
+ }
+ }
+
test(s"Paimon migrate table procedure: migrate partitioned table with null
partition") {
withTable(s"hive_tbl$random") {
// create hive table