Skip to content

Commit

Permalink
Skip dropping testing Glue database when create time is within threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Sep 20, 2023
1 parent 6754df7 commit 8c460fd
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import com.amazonaws.services.glue.AWSGlueAsync;
import com.amazonaws.services.glue.AWSGlueAsyncClientBuilder;
import com.amazonaws.services.glue.model.Database;
import com.amazonaws.services.glue.model.GetDatabaseRequest;
import com.amazonaws.services.glue.model.GetTableRequest;
import com.amazonaws.services.glue.model.Table;
import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -69,6 +71,12 @@ public void testCleanUpOldTablesUsingDelta()

private void cleanSchema(String schema, long startTime, AWSGlueAsync glueClient)
{
Database database = glueClient.getDatabase(new GetDatabaseRequest().withName(schema)).getDatabase();
if (database.getCreateTime().toInstant().isAfter(SCHEMA_CLEANUP_THRESHOLD)) {
log.info("Skip dropping recently created schema %s", schema);
return;
}

Set<String> allTestTableNames = findAllTablesInSchema(schema).stream()
.filter(name -> name.toLowerCase(ENGLISH).startsWith("test"))
.collect(toImmutableSet());
Expand Down

0 comments on commit 8c460fd

Please sign in to comment.