Posts tagged with: tricks

Hive tips & tricks

in Hive CLI, see the headers when executing a request :

hive> select * from sample_07 limit 2;
OK
00-0000 All Occupations 134354250 40690
11-0000 Management occupations 6003930 96150
Time taken: 1.313 seconds, Fetched: 2 row(s)
hive> set hive.cli.print.header=true;
hive> select * from sample_07 limit 2;
OK
sample_07.code sample_07.description sample_07.total_emp sample_07.salary
00-0000 All Occupations 134354250 40690
11-0000 Management occupations 6003930 96150
Time taken: 1.199 seconds, Fetched: 2 row(s)

include the database in the Hive prompt :

hive> set hive.cli.print.current.db=true;
hive (default)>

 

When you want to merge small files in a Hive partition, you have to simple solutions :

* from Hive 0.14, use CONCATENATE

ALTER TABLE table_name [PARTITION (partition_key = 'partition_value' [, ...])] CONCATENATE;

* or you can use the ARCHIVE command to merge to HAR (Hadoop ARchive) file

hive> set hive.archive.enabled=true;
hive> set har.partfile.size=1099511627776;
hive> ALTER TABLE tabname ARCHIVE PARTITION (dt_partition='2015-03-10');