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 a6d5c212a12b58..4e80d7466d2f91 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 bac891eb920225..f92c2e545ac6f0 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.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 List getFilesByTransaction(List partitions 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 e4c6a6c6d24ac5..36bd721168e224 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 6c8d4d100b310c..a34ef7adc271df 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")) {