0

I'm trying to create a bucket in hive by using following commands:

hive> create table emp( id int, name string, country string)
 clustered by( country)
row format delimited
fields terminated by ','
stored as textfile ;

Command is executing successfully: when I load data into this table, it executes successfully and all data is shown when using select * from emp.

However, on HDFS it is only creating one table and only one file is there with all data. That is, there is no folder for specific country records.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • It seems hard to understand what your question is... – coderz Apr 05 '15 at 14:58
  • ok , after creating table as above i have load data into it but when i browse it on hdfs there is only one table/file containing all data i.e. buckets are not creating on hdfs – Amit Pandey Apr 05 '15 at 17:20

1 Answers1

1

First of all, in the DDL statement you have to explicitly mention how many buckets you want.

create table emp( id int, name string, country string)
 clustered by( country)
INTO 2 BUCKETS
row format delimited
fields terminated by ','
stored as textfile ;

In the above statement I have mention 2 buckets, similarly you can mention any number you want.

Still you are not done!!

After that, while loading data into the table you also have to mention the below hint to hive.

set hive.enforce.bucketing = true;  

That should do it.

After this you should be able to see that number of files created under the table directory is same as the number of buckets mentioned in the DDL statement.

Bucketing doesn't create HDFS folders, rather if you want a separate floder to be created for a country then you should PARTITION.

Please go through hive partitioning and bucketing in detail.

sunil
  • 1,259
  • 1
  • 14
  • 27
  • is there any way that i can get records under records that file author=A as 10 files in of their documents , not their merge records in same file. that is file created on row slicing and access able from one file to all files – Amit Pandey Apr 08 '15 at 09:11