Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix](hive-transactional-table) Fix NPE when query empty hive transactional table. #27567

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -789,6 +790,9 @@ public List<FileCacheValue> getFilesByTransaction(List<HivePartition> 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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ A
B
CC

-- !q03 --
3 CC
-- !q04 --

-- !q05 --
0

-- !q01 --
1 A 20230101
Expand All @@ -31,3 +33,8 @@ F
-- !q03 --
2 BB 20230101

-- !q04 --

-- !q05 --
0

Original file line number Diff line number Diff line change
Expand Up @@ -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;
"""
}

Expand All @@ -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")) {
Expand Down
Loading