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

yiguolei pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 9f277a0a2b1 [Fix](hive-transactional-table) Fix NPE when query empty 
hive transactional table. (#27567)
9f277a0a2b1 is described below

commit 9f277a0a2b1ce2c6672fe68681ec0b0f3c02018a
Author: Qi Chen <kaka11.c...@gmail.com>
AuthorDate: Sat Nov 25 16:50:13 2023 +0800

    [Fix](hive-transactional-table) Fix NPE when query empty hive transactional 
table. (#27567)
---
 .../hive/scripts/create_preinstalled_table.hql              | 11 +++++++++++
 .../apache/doris/datasource/hive/HiveMetaStoreCache.java    |  4 ++++
 .../data/external_table_p0/hive/test_transactional_hive.out | 11 +++++++++--
 .../external_table_p0/hive/test_transactional_hive.groovy   | 13 +++++++++++--
 4 files changed, 35 insertions(+), 4 deletions(-)

diff --git 
a/docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_table.hql 
b/docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_table.hql
index a6d5c212a12..4e80d7466d2 100644
--- 
a/docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_table.hql
+++ 
b/docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_table.hql
@@ -632,6 +632,17 @@ insert into `schema_evo_test_orc` select 2, "messi", 
from_unixtime(to_unix_times
 SET hive.support.concurrency=true;
 SET hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
 
+create table orc_full_acid_empty (id INT, value STRING)
+CLUSTERED BY (id) INTO 3 BUCKETS
+STORED AS ORC
+TBLPROPERTIES ('transactional' = 'true');
+
+create table orc_full_acid_par_empty (id INT, value STRING)
+PARTITIONED BY (part_col INT)
+CLUSTERED BY (id) INTO 3 BUCKETS
+STORED AS ORC
+TBLPROPERTIES ('transactional' = 'true');
+
 create table orc_full_acid (id INT, value STRING)
 CLUSTERED BY (id) INTO 3 BUCKETS
 STORED AS ORC
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
index bac891eb920..f92c2e545ac 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
@@ -90,6 +90,7 @@ import java.io.FileNotFoundException;
 import java.net.URI;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -789,6 +790,9 @@ public class HiveMetaStoreCache {
                     directory = AcidUtils.getAcidState(new 
Path(partition.getPath()), jobConf, validWriteIds, false,
                             true);
                 }
+                if (directory == null || directory.getBaseDirectory() == null) 
{
+                    return Collections.emptyList();
+                }
                 if (!directory.getOriginalFiles().isEmpty()) {
                     throw new Exception("Original non-ACID files in 
transactional tables are not supported");
                 }
diff --git 
a/regression-test/data/external_table_p0/hive/test_transactional_hive.out 
b/regression-test/data/external_table_p0/hive/test_transactional_hive.out
index e4c6a6c6d24..36bd721168e 100644
--- a/regression-test/data/external_table_p0/hive/test_transactional_hive.out
+++ b/regression-test/data/external_table_p0/hive/test_transactional_hive.out
@@ -9,8 +9,10 @@ A
 B
 CC
 
--- !q03 --
-3      CC
+-- !q04 --
+
+-- !q05 --
+0
 
 -- !q01 --
 1      A       20230101
@@ -31,3 +33,8 @@ F
 -- !q03 --
 2      BB      20230101
 
+-- !q04 --
+
+-- !q05 --
+0
+
diff --git 
a/regression-test/suites/external_table_p0/hive/test_transactional_hive.groovy 
b/regression-test/suites/external_table_p0/hive/test_transactional_hive.groovy
index 6c8d4d100b3..a34ef7adc27 100644
--- 
a/regression-test/suites/external_table_p0/hive/test_transactional_hive.groovy
+++ 
b/regression-test/suites/external_table_p0/hive/test_transactional_hive.groovy
@@ -23,8 +23,11 @@ suite("test_transactional_hive", 
"p0,external,hive,external_docker,external_dock
         qt_q02 """
         select value from orc_full_acid order by id;
         """
-        qt_q03 """
-        select * from orc_full_acid where value = 'CC' order by id;
+        qt_q04 """
+        select * from orc_full_acid_empty;
+        """
+        qt_q05 """
+        select count(*) from orc_full_acid_empty;
         """
     }
 
@@ -38,6 +41,12 @@ suite("test_transactional_hive", 
"p0,external,hive,external_docker,external_dock
         qt_q03 """
         select * from orc_full_acid_par where value = 'BB' order by id;
         """
+        qt_q04 """
+        select * from orc_full_acid_par_empty;
+        """
+        qt_q05 """
+        select count(*) from orc_full_acid_par_empty;
+        """
     }
     String enabled = context.config.otherConfigs.get("enableHiveTest")
     if (enabled != null && enabled.equalsIgnoreCase("true")) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to