Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza Jugon committed Nov 25, 2024
1 parent 1be81b8 commit 66ad261
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class S3DryRunPathCleanerTest {

private HousekeepingPath housekeepingPath;
private AmazonS3 amazonS3;
private @Mock BytesDeletedReporter bytesDeletedReporter;
@Mock private BytesDeletedReporter bytesDeletedReporter;
@Mock private IcebergValidator icebergValidator;

private boolean dryRunEnabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,24 +302,23 @@ public void cleanupSentinelForNonEmptyParent() throws SQLException, TException {

@Test
public void shouldSkipCleanupForIcebergTable() throws Exception {
// add iceberg table props
Map<String, String> tableProperties = new HashMap<>();
tableProperties.put("table_type", "ICEBERG");
tableProperties.put("format", "ICEBERG/PARQUET");
String outputFormat = "org.apache.iceberg.mr.hive.HiveIcebergOutputFormat";
// create iceberg table

hiveTestUtils.createTableWithProperties(
TABLE_PATH, TABLE_NAME_VALUE, false, tableProperties, outputFormat, true);
// add data

String objectKey = DATABASE_NAME_VALUE + "/" + TABLE_NAME_VALUE + "/file1";
amazonS3.putObject(BUCKET, objectKey, CONTENT);
// insert housekeepingPath record
String path = "s3://" + BUCKET + "/" + DATABASE_NAME_VALUE + "/" + TABLE_NAME_VALUE + "/";
insertUnreferencedPath(path); // Uses default database and table names
// wait for the cleanup process to run and update to skipped

amazonS3.putObject(BUCKET, objectKey, CONTENT);
insertUnreferencedPath(path);

await().atMost(TIMEOUT, TimeUnit.SECONDS)
.until(() -> getUnreferencedPaths().get(0).getHousekeepingStatus() == SKIPPED);
// verify that the data in S3 is still present

assertThat(amazonS3.doesObjectExist(BUCKET, objectKey))
.withFailMessage("S3 object %s should still exist as cleanup was skipped.", objectKey)
.isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public Table createTableWithProperties(String path, String tableName, boolean pa
hiveTable.setTableType(TableType.EXTERNAL_TABLE.name());
hiveTable.putToParameters("EXTERNAL", "TRUE");

// Add custom table props
if (tableProperties != null) {
hiveTable.getParameters().putAll(tableProperties);
}
Expand All @@ -135,7 +134,7 @@ public Table createTableWithProperties(String path, String tableName, boolean pa
sd.setCols(DATA_COLUMNS);
sd.setLocation(path);
sd.setParameters(new HashMap<>());
// Set the output format for the storage descriptor, defaulting to TextOutputFormat if not specified

if (outputFormat != null) {
sd.setOutputFormat(outputFormat);
} else {
Expand Down

0 comments on commit 66ad261

Please sign in to comment.