Skip to content

Commit

Permalink
add event
Browse files Browse the repository at this point in the history
  • Loading branch information
javsanbel2 committed Nov 27, 2024
1 parent a32e9d0 commit 9a93bd7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,21 @@ public void expiredMetadataMultipleAlterPartitionTableEvents() throws SQLExcepti
assertExpiredMetadata(expiredMetadata.get(1), LOCATION_B, PARTITION_B_NAME);
}

@Test
public void expiredMetadataAlterIcebergTableEventShouldBeIgnored()
throws SQLException, IOException, URISyntaxException {
insertExpiredMetadata(LOCATION_A + "-old", null);

AlterTableSqsMessage alterTableSqsMessage = new AlterTableSqsMessage(LOCATION_A, true, true);
amazonSQS.sendMessage(sendMessageRequest(alterTableSqsMessage.getFormattedString()));

await().atMost(TIMEOUT, TimeUnit.SECONDS).until(() -> getUpdatedExpiredMetadataRowCount() == 1);

// iceberg table event should be ignored
List<HousekeepingMetadata> expiredMetadata = getExpiredMetadata();
assertThat(expiredMetadata.size()).isEqualTo(0);
}

@Test
public void healthCheck() {
CloseableHttpClient client = HttpClientBuilder.create().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ public AlterTableSqsMessage(
setExpired(isExpired);
}

public AlterTableSqsMessage(
String tableLocation,
boolean isExpired,
boolean isIceberg
) throws IOException, URISyntaxException {
super(ALTER_TABLE);
setTableLocation(tableLocation);
setOldTableLocation(DUMMY_LOCATION);
setOldTableName(TABLE_NAME_VALUE);
setExpired(isExpired);
if (isIceberg) {
setIceberg();
}
}

public void setOldTableLocation(String oldTableLocation) {
apiaryEventMessageJsonObject.add(EVENT_TABLE_OLD_LOCATION_KEY, new JsonPrimitive(oldTableLocation));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ public void setExpired(boolean isExpired) {
tableParameters.add(EXPIRED_DATA_RETENTION_PERIOD_PROPERTY_KEY, new JsonPrimitive(SHORT_CLEANUP_DELAY_VALUE));
}

public void setIceberg() {
JsonObject tableParameters = apiaryEventMessageJsonObject.getAsJsonObject(EVENT_TABLE_PARAMETERS_KEY);
tableParameters.add("table_format", new JsonPrimitive("ICEBERG"));
tableParameters.add("metadata_location", new JsonPrimitive("s3://bucket/metadata"));
}

public void setWhitelisted(boolean isWhitelisted) {
String whitelist = isWhitelisted ? eventType.toString() : "";
JsonObject tableParameters = apiaryEventMessageJsonObject.getAsJsonObject(EVENT_TABLE_PARAMETERS_KEY);
Expand Down

0 comments on commit 9a93bd7

Please sign in to comment.