>create table bucket1(id int,name string)
> clustered by(id) into 5 buckets;
> create table user(id int,name string)
> row format delimited
> fields terminated by ','
> lines terminated by '\n'
> stored as textfile;
SET hive.exec.dynamic.partition= true;
SET hive.exec.dynamic.partition.mode= nonstrict;
SET hive.enforce.bucketing=true;
1,aaa
2,bbb
3,ccc
4,ddd
4,eee
5,fff
13,ggg
12,hhh
13,kkk
6,rrr
17,ppp
18,wer
8,qwe
load data local inpath 'users.txt' overwrite into table user;
------------------------------------------
hive> insert overwrite table bucket1
> select id,name from user;
-----------------------------------------
[training@localhost ~]$ hadoop fs -cat /user/hive/warehouse/emp.db/bucket1/000000_0
THE user data splitted in to different buckets by corresponding hash mapping
> clustered by(id) into 5 buckets;
> create table user(id int,name string)
> row format delimited
> fields terminated by ','
> lines terminated by '\n'
> stored as textfile;
SET hive.exec.dynamic.partition= true;
SET hive.exec.dynamic.partition.mode= nonstrict;
SET hive.enforce.bucketing=true;
1,aaa
2,bbb
3,ccc
4,ddd
4,eee
5,fff
13,ggg
12,hhh
13,kkk
6,rrr
17,ppp
18,wer
8,qwe
load data local inpath 'users.txt' overwrite into table user;
------------------------------------------
hive> insert overwrite table bucket1
> select id,name from user;
-----------------------------------------
[training@localhost ~]$ hadoop fs -cat /user/hive/warehouse/emp.db/bucket1/000000_0
THE user data splitted in to different buckets by corresponding hash mapping
No comments:
Post a Comment