From 8c460fd6b5784b641a363a276770344eee212ab7 Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Wed, 20 Sep 2023 17:15:31 +0900 Subject: [PATCH] Skip dropping testing Glue database when create time is within threshold --- .../deltalake/TestDatabricksWithGlueMetastoreCleanUp.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDatabricksWithGlueMetastoreCleanUp.java b/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDatabricksWithGlueMetastoreCleanUp.java index f728dcdb8c45..b51cc3fd5f42 100644 --- a/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDatabricksWithGlueMetastoreCleanUp.java +++ b/testing/trino-product-tests/src/main/java/io/trino/tests/product/deltalake/TestDatabricksWithGlueMetastoreCleanUp.java @@ -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; @@ -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 allTestTableNames = findAllTablesInSchema(schema).stream() .filter(name -> name.toLowerCase(ENGLISH).startsWith("test")) .collect(toImmutableSet());