This is an automated email from the ASF dual-hosted git repository.

pwason pushed a commit to branch release-0.14.0
in repository https://gitbox.apache.org/repos/asf/hudi.git

commit 8b273631cfde855478d677a679f4365102e06f6b
Author: Shawn Chang <[email protected]>
AuthorDate: Sat Sep 2 04:06:37 2023 -0700

    [MINOR] Catch EntityNotFoundException correctly (#9595)
    
    When table/database is not found when syncing table to Glue, glue should 
return `EntityNotFoundException`.
    After upgrading to AWS SDK V2, Hudi uses `GlueAsyncClient` to get a 
`CompletableFuture`, which would throw `ExecutionException` with 
`EntityNotFoundException` nested when table/database doesn't exist. However, 
existing Hudi code doesn't handle `ExecutionException` and would fail the job.
    
    ---------
    
    Co-authored-by: Shawn Chang <[email protected]>
---
 .../hudi/aws/sync/AWSGlueCatalogSyncClient.java     | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git 
a/hudi-aws/src/main/java/org/apache/hudi/aws/sync/AWSGlueCatalogSyncClient.java 
b/hudi-aws/src/main/java/org/apache/hudi/aws/sync/AWSGlueCatalogSyncClient.java
index d45cc76a6bc..a76ca86894a 100644
--- 
a/hudi-aws/src/main/java/org/apache/hudi/aws/sync/AWSGlueCatalogSyncClient.java
+++ 
b/hudi-aws/src/main/java/org/apache/hudi/aws/sync/AWSGlueCatalogSyncClient.java
@@ -67,6 +67,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
 
 import static org.apache.hudi.aws.utils.S3Utils.s3aToS3;
@@ -456,9 +457,13 @@ public class AWSGlueCatalogSyncClient extends 
HoodieSyncClient {
         .build();
     try {
       return Objects.nonNull(awsGlue.getTable(request).get().table());
-    } catch (EntityNotFoundException e) {
-      LOG.info("Table not found: " + tableId(databaseName, tableName), e);
-      return false;
+    } catch (ExecutionException e) {
+      if (e.getCause() instanceof EntityNotFoundException) {
+        LOG.info("Table not found: " + tableId(databaseName, tableName), e);
+        return false;
+      } else {
+        throw new HoodieGlueSyncException("Fail to get table: " + 
tableId(databaseName, tableName), e);
+      }
     } catch (Exception e) {
       throw new HoodieGlueSyncException("Fail to get table: " + 
tableId(databaseName, tableName), e);
     }
@@ -469,9 +474,13 @@ public class AWSGlueCatalogSyncClient extends 
HoodieSyncClient {
     GetDatabaseRequest request = 
GetDatabaseRequest.builder().name(databaseName).build();
     try {
       return Objects.nonNull(awsGlue.getDatabase(request).get().database());
-    } catch (EntityNotFoundException e) {
-      LOG.info("Database not found: " + databaseName, e);
-      return false;
+    } catch (ExecutionException e) {
+      if (e.getCause() instanceof EntityNotFoundException) {
+        LOG.info("Database not found: " + databaseName, e);
+        return false;
+      } else {
+        throw new HoodieGlueSyncException("Fail to check if database exists " 
+ databaseName, e);
+      }
     } catch (Exception e) {
       throw new HoodieGlueSyncException("Fail to check if database exists " + 
databaseName, e);
     }

Reply via email to