Skip to content

Commit d2d7dd2

Browse files
authored
HIVE-27190: Fix cache-key collisions for time-travel queries on Iceberg (apache#6380)
1 parent 3d21fc4 commit d2d7dd2

10 files changed

Lines changed: 499 additions & 59 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
set hive.fetch.task.conversion=none;
2+
set hive.explain.user=false;
3+
4+
create external table tbl_ice_pp_key(a int, b string)
5+
partitioned by spec (a) stored by iceberg;
6+
7+
insert into tbl_ice_pp_key values (1, 'one'), (2, 'two');
8+
alter table tbl_ice_pp_key create tag s1;
9+
10+
insert into tbl_ice_pp_key values
11+
(3, 'three'), (4, 'four'), (5, 'five'),
12+
(6, 'six'), (7, 'seven'),(8, 'eight'),
13+
(9, 'nine'), (10, 'ten');
14+
15+
explain select count(*) from tbl_ice_pp_key;
16+
select count(*) from tbl_ice_pp_key;
17+
18+
explain select count(*) from tbl_ice_pp_key for system_version as of 's1';
19+
select count(*) from tbl_ice_pp_key for system_version as of 's1';
20+
21+
explain
22+
select cur.cnt as cur_cnt, snap.cnt as snap_cnt
23+
from (
24+
select count(*) as cnt from tbl_ice_pp_key
25+
) cur
26+
cross join (
27+
select count(*) as cnt from tbl_ice_pp_key for system_version as of 's1'
28+
) snap;
29+
30+
select cur.cnt as cur_cnt, snap.cnt as snap_cnt
31+
from (
32+
select count(*) as cnt from tbl_ice_pp_key
33+
) cur
34+
cross join (
35+
select count(*) as cnt from tbl_ice_pp_key for system_version as of 's1'
36+
) snap;
37+
38+
-- with a partition predicate
39+
explain
40+
select 'current' as ver, count(*) as cnt from tbl_ice_pp_key where a > 2
41+
union all
42+
select 'asof_s1' as ver, count(*) as cnt from tbl_ice_pp_key for system_version as of 's1'
43+
where a > 2;
44+
45+
select 'current' as ver, count(*) as cnt from tbl_ice_pp_key where a > 2
46+
union all
47+
select 'asof_s1' as ver, count(*) as cnt from tbl_ice_pp_key for system_version as of 's1'
48+
where a > 2;
49+
50+
drop table tbl_ice_pp_key;

iceberg/iceberg-handler/src/test/results/positive/iceberg_metadata_table_alias.q.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ POSTHOOK: type: QUERY
2323
POSTHOOK: Input: default@ice_t
2424
POSTHOOK: Output: hdfs://### HDFS PATH ###
2525
OPTIMIZED SQL: SELECT `committed_at` AS `ice_t.snapshots.committed_at`, `snapshot_id` AS `ice_t.snapshots.snapshot_id`, `parent_id` AS `ice_t.snapshots.parent_id`, `operation` AS `ice_t.snapshots.operation`, `manifest_list` AS `ice_t.snapshots.manifest_list`, `summary` AS `ice_t.snapshots.summary`
26-
FROM `default`.`ice_t`
26+
FROM `default`.`ice_t`.`snapshots`
2727
STAGE DEPENDENCIES:
2828
Stage-0 is a root stage
2929

0 commit comments

Comments
 (0)