Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza Jugon committed Nov 24, 2024
1 parent a09e9f1 commit 8c1ce38
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public IcebergValidator(CleanerClientFactory cleanerClientFactory) {
}

/**
* Beekeeper does not support Iceberg format right now. Iceberg tables in Hive Metastore do not store partition information,
* so Beekeeper tries to clean up the entire table because that information is missing. This method checks if
* the table is an Iceberg table and throws IcebergTableFoundException to stop the process.
* Beekeeper currently does not support the Iceberg format. Iceberg tables in the Hive Metastore do not store partition information,
* causing Beekeeper to attempt to clean up the entire table due to the missing information. This method checks if
* the table is an Iceberg table and throws a BeekeeperIcebergException to stop the process.
*
* @param databaseName
* @param tableName
Expand All @@ -53,13 +53,11 @@ public void throwExceptionIfIceberg(String databaseName, String tableName) {
if (tableType.contains("iceberg") || format.contains("iceberg") || (outputFormat != null
&& outputFormat.toLowerCase().contains("iceberg"))) {
throw new BeekeeperIcebergException(
format("Iceberg table %s.%s is not currently supported in Beekeeper.", databaseName,
tableName));
format("Iceberg table %s.%s is not currently supported in Beekeeper.", databaseName, tableName));
}
} catch (Exception e) {
throw new BeekeeperIcebergException(
format("Unexpected exception when identifying if table %s.%s is Iceberg.", databaseName,
tableName), e);
format("Unexpected exception when identifying if table %s.%s is Iceberg.", databaseName, tableName), e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -383,18 +383,6 @@ void shouldThrowBeekeeperIcebergExceptionWhenIcebergTableDetected() {
verifyNoInteractions(bytesDeletedReporter);
}

@Test
void shouldNotReportBytesDeletedWhenIcebergValidatorThrows() {
doThrow(new BeekeeperIcebergException("Iceberg tables are not supported"))
.when(icebergValidator)
.throwExceptionIfIceberg(housekeepingPath.getDatabaseName(), housekeepingPath.getTableName());

assertThatExceptionOfType(BeekeeperIcebergException.class)
.isThrownBy(() -> s3PathCleaner.cleanupPath(housekeepingPath));

verify(bytesDeletedReporter, never()).reportTaggable(anyLong(), any(), any());
}

@Test
void shouldProceedWithDeletionWhenNotIcebergTable() {
// setting up objects in the bucket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void tableExists() {
}

@Test
public void dropTableWhenIcebergTable() {
public void doesNotDropTableWhenIcebergTable() {
when(housekeepingMetadata.getDatabaseName()).thenReturn(DATABASE);
when(housekeepingMetadata.getTableName()).thenReturn(TABLE_NAME);
doThrow(new BeekeeperIcebergException("Iceberg table"))
Expand All @@ -106,13 +106,12 @@ public void dropTableWhenIcebergTable() {
() -> cleaner.dropTable(housekeepingMetadata, hiveClient)
);

// Verify that dropTable was not called on hiveClient
verify(hiveClient, never()).dropTable(DATABASE, TABLE_NAME);
verify(deletedMetadataReporter, never()).reportTaggable(housekeepingMetadata, MetadataType.HIVE_TABLE);
}

@Test
public void dropPartitionWhenIcebergTable() {
public void doesNotDropPartitionWhenIcebergTable() {
when(housekeepingMetadata.getDatabaseName()).thenReturn(DATABASE);
when(housekeepingMetadata.getTableName()).thenReturn(TABLE_NAME);
doThrow(new BeekeeperIcebergException("Iceberg table"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,26 @@ public void shouldThrowExceptionWhenOutputFormatContainsIceberg() throws Excepti

icebergValidator.throwExceptionIfIceberg("db", "table");
}

@Test(expected = BeekeeperIcebergException.class)
public void shouldThrowExceptionWhenFormatIsNullButTableTypeIsIceberg() throws Exception {
Map<String, String> properties = new HashMap<>();
properties.put("table_type", "ICEBERG");

when(cleanerClient.getTableProperties("db", "table")).thenReturn(properties);
when(cleanerClient.getOutputFormat("db", "table")).thenReturn("");

icebergValidator.throwExceptionIfIceberg("db", "table");
}

@Test
public void shouldNotThrowExceptionWhenOutputFormatIsNull() throws Exception {
Map<String, String> properties = new HashMap<>();
properties.put("table_type", "HIVE_TABLE");

when(cleanerClient.getTableProperties("db", "table")).thenReturn(properties);
when(cleanerClient.getOutputFormat("db", "table")).thenReturn(null);

icebergValidator.throwExceptionIfIceberg("db", "table");
}
}

0 comments on commit 8c1ce38

Please sign in to comment.