[HUDI-3138] Fix broken UT test for TestHiveSyncTool.testDropPartitions (#4493)
Co-authored-by: yuezhang <yuezhang@freewheel.tv>
This commit is contained in:
@@ -812,12 +812,14 @@ public class TestHiveSyncTool {
|
|||||||
assertEquals(hiveClient.getTableSchema(HiveTestUtil.hiveSyncConfig.tableName).size(),
|
assertEquals(hiveClient.getTableSchema(HiveTestUtil.hiveSyncConfig.tableName).size(),
|
||||||
hiveClient.getDataSchema().getColumns().size() + 1,
|
hiveClient.getDataSchema().getColumns().size() + 1,
|
||||||
"Hive Schema should match the table schema + partition field");
|
"Hive Schema should match the table schema + partition field");
|
||||||
assertEquals(1, hiveClient.scanTablePartitions(hiveSyncConfig.tableName).size(),
|
List<Partition> partitions = hiveClient.scanTablePartitions(hiveSyncConfig.tableName);
|
||||||
|
assertEquals(1, partitions.size(),
|
||||||
"Table partitions should match the number of partitions we wrote");
|
"Table partitions should match the number of partitions we wrote");
|
||||||
assertEquals(instantTime, hiveClient.getLastCommitTimeSynced(hiveSyncConfig.tableName).get(),
|
assertEquals(instantTime, hiveClient.getLastCommitTimeSynced(hiveSyncConfig.tableName).get(),
|
||||||
"The last commit that was synced should be updated in the TBLPROPERTIES");
|
"The last commit that was synced should be updated in the TBLPROPERTIES");
|
||||||
// create a replace commit to delete current partitions
|
String partitiontoDelete = partitions.get(0).getValues().get(0).replace("-","/");
|
||||||
HiveTestUtil.createReplaceCommit("101", "2021/12/28", WriteOperationType.DELETE_PARTITION);
|
// create a replace commit to delete current partitions+
|
||||||
|
HiveTestUtil.createReplaceCommit("101", partitiontoDelete, WriteOperationType.DELETE_PARTITION, true, true);
|
||||||
|
|
||||||
// sync drop partitins
|
// sync drop partitins
|
||||||
tool = new HiveSyncTool(hiveSyncConfig, HiveTestUtil.getHiveConf(), fileSystem);
|
tool = new HiveSyncTool(hiveSyncConfig, HiveTestUtil.getHiveConf(), fileSystem);
|
||||||
|
|||||||
@@ -178,9 +178,10 @@ public class HiveTestUtil {
|
|||||||
createCommitFile(commitMetadata, instantTime);
|
createCommitFile(commitMetadata, instantTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createReplaceCommit(String instantTime, String partitions, WriteOperationType type)
|
public static void createReplaceCommit(String instantTime, String partitions, WriteOperationType type, boolean isParquetSchemaSimple, boolean useSchemaFromCommitMetadata)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
HoodieReplaceCommitMetadata replaceCommitMetadata = new HoodieReplaceCommitMetadata();
|
HoodieReplaceCommitMetadata replaceCommitMetadata = new HoodieReplaceCommitMetadata();
|
||||||
|
addSchemaToCommitMetadata(replaceCommitMetadata, isParquetSchemaSimple, useSchemaFromCommitMetadata);
|
||||||
replaceCommitMetadata.setOperationType(type);
|
replaceCommitMetadata.setOperationType(type);
|
||||||
Map<String, List<String>> partitionToReplaceFileIds = new HashMap<>();
|
Map<String, List<String>> partitionToReplaceFileIds = new HashMap<>();
|
||||||
partitionToReplaceFileIds.put(partitions, new ArrayList<>());
|
partitionToReplaceFileIds.put(partitions, new ArrayList<>());
|
||||||
|
|||||||
Reference in New Issue
Block a user