Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip dropping testing Glue database when create time is within threshold #19101

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, pre-existing, SCHEMA_CLEANUP_THRESHOLD shouldn't be a static constant
it doesn't matter when class was loaded in current JVM. it matters when cleanup code was invoked.

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