You are on page 1of 1

shell commands:-

$ hdfs dfs -mkdir /store

hive commands:-

$ hive

hive> create database hive_part;


hive> use hive_part;
hive> create table temp (transaction_id string, cust_id int, tran_date string,
prod_subcat_code int, prod_cat_code int, Qty int, Rate int, Tax double, total_amt
double, Store_type string)
> row format delimited
> fields terminated by ',' lines terminated by '\n'
> tblproperties("skip.header.line.count"="1");
hive> load data local inpath '/projects/challenge/Transactions.csv' into table
temp;
hive> create table transaction_part (transaction_id string, cust_id int, tran_date
string, Qty int, Rate int, Tax double, total_amt double)
> partitioned by (Store_type string)
> row format delimited
> fields terminated by ',' lines terminated by '\n'
> tblproperties("skip.header.line.count"="1");
hive> set hive.exec.dynamic.partition=true;
hive> set hive.exec.dynamic.partition.mode=nonstrict;
hive> insert into table transaction_part partition (Store_type)
> select transaction_id, cust_id, tran_date, Qty, Rate, Tax, total_amt,
Store_type from temp where Qty > 2;
hive> insert overwrite directory '/store' row format delimited fields terminated by
',' lines terminated by '\n' stored as textfile select * from transaction_part
where Store_type="e-Shop";

You might also like