1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
set hive.merge.mapfiles=false;
set hive.merge.mapredfiles=false;
set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
create table merge_src as
select key, value from srcpart where ds is not null;
create table merge_src_part (key string, value string) partitioned by (ds string);
insert overwrite table merge_src_part partition(ds) select key, value, ds from srcpart where ds is not null;
set hive.merge.mapfiles=true;
set hive.merge.mapredfiles=true;
explain extended
create table merge_src2 as
select key, value from merge_src;
create table merge_src2 as
select key, value from merge_src;
select * from merge_src2 ORDER BY key ASC, value ASC;
describe formatted merge_src2;
create table merge_src_part2 like merge_src_part;
explain extended
insert overwrite table merge_src_part2 partition(ds)
select key, value, ds from merge_src_part
where ds is not null;
insert overwrite table merge_src_part2 partition(ds)
select key, value, ds from merge_src_part
where ds is not null;
show partitions merge_src_part2;
select * from merge_src_part2 where ds is not null ORDER BY key ASC, value ASC;
drop table merge_src_part2;
create table merge_src_part2 like merge_src_part;
explain extended
from (select * from merge_src_part where ds is not null distribute by ds) s
insert overwrite table merge_src_part2 partition(ds)
select key, value, ds;
from (select * from merge_src_part where ds is not null distribute by ds) s
insert overwrite table merge_src_part2 partition(ds)
select key, value, ds;
show partitions merge_src_part2;
select * from merge_src_part2 where ds is not null ORDER BY key ASC, value ASC;
|