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

ayushsaxena pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 470abfb9d8e HIVE-27452: Fix possible FNFE in 
HiveQueryLifeTimeHook::checkAndRollbackCTAS (#4437). (Sourabh Badhya, reviewed 
by Denys Kuzmenko, Ayush Saxena)
470abfb9d8e is described below

commit 470abfb9d8e9ec375ca7f07434ff862a8f136bd1
Author: Sourabh Badhya <iamsbad...@gmail.com>
AuthorDate: Wed Jun 21 16:39:49 2023 +0530

    HIVE-27452: Fix possible FNFE in 
HiveQueryLifeTimeHook::checkAndRollbackCTAS (#4437). (Sourabh Badhya, reviewed 
by Denys Kuzmenko, Ayush Saxena)
---
 .../java/org/apache/hadoop/hive/ql/HiveQueryLifeTimeHook.java  | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/HiveQueryLifeTimeHook.java 
b/ql/src/java/org/apache/hadoop/hive/ql/HiveQueryLifeTimeHook.java
index 9e21b586e0f..a32a81e6f23 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/HiveQueryLifeTimeHook.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/HiveQueryLifeTimeHook.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hive.ql;
 
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.api.CompactionRequest;
@@ -74,6 +75,15 @@ public class HiveQueryLifeTimeHook implements 
QueryLifeTimeHook {
     PrivateHookContext pCtx = (PrivateHookContext) ctx.getHookContext();
     Path tblPath = pCtx.getContext().getLocation();
 
+    try {
+      FileSystem fs = tblPath.getFileSystem(conf);
+      if (!fs.exists(tblPath)) {
+        return;
+      }
+    } catch (Exception e) {
+      throw new RuntimeException("Not able to check whether the CTAS table 
directory exists due to: ", e);
+    }
+
     if (isCTAS && tblPath != null) {
       boolean isSoftDeleteEnabled = tblPath.getName().matches("(.*)" + 
SOFT_DELETE_TABLE_PATTERN);
 

Reply via email to