Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,22 @@ public void executeMigrate() throws Exception {
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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down