Skip to content
Permalink
Browse files
[HUDI-3138] Fix broken UT test for TestHiveSyncTool.testDropPartitions (
#4493)

Co-authored-by: yuezhang <yuezhang@freewheel.tv>
  • Loading branch information
zhangyue19921010 and yuezhang committed Jan 3, 2022
1 parent fe9406d commit 1e2d2c437d5ec73452b276cdaff5a789ea3979ac
Showing 2 changed files with 7 additions and 4 deletions.
@@ -812,12 +812,14 @@ public void testDropPartition(String syncMode) throws Exception {
assertEquals(hiveClient.getTableSchema(HiveTestUtil.hiveSyncConfig.tableName).size(),
hiveClient.getDataSchema().getColumns().size() + 1,
"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");
assertEquals(instantTime, hiveClient.getLastCommitTimeSynced(hiveSyncConfig.tableName).get(),
"The last commit that was synced should be updated in the TBLPROPERTIES");
// create a replace commit to delete current partitions
HiveTestUtil.createReplaceCommit("101", "2021/12/28", WriteOperationType.DELETE_PARTITION);
String partitiontoDelete = partitions.get(0).getValues().get(0).replace("-","/");
// create a replace commit to delete current partitions+
HiveTestUtil.createReplaceCommit("101", partitiontoDelete, WriteOperationType.DELETE_PARTITION, true, true);

// sync drop partitins
tool = new HiveSyncTool(hiveSyncConfig, HiveTestUtil.getHiveConf(), fileSystem);
@@ -178,9 +178,10 @@ public static void createCOWTable(String instantTime, int numberOfPartitions, bo
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 {
HoodieReplaceCommitMetadata replaceCommitMetadata = new HoodieReplaceCommitMetadata();
addSchemaToCommitMetadata(replaceCommitMetadata, isParquetSchemaSimple, useSchemaFromCommitMetadata);
replaceCommitMetadata.setOperationType(type);
Map<String, List<String>> partitionToReplaceFileIds = new HashMap<>();
partitionToReplaceFileIds.put(partitions, new ArrayList<>());

0 comments on commit 1e2d2c4

Please sign in to comment.