Method 1
Tmp_channel_hive_file= "/tmp/tmp_channel_hive_file"
tmp_channel_hive_file_new= "/tmp/tmp_channel_hive_file_new"
db= "T_merchant_shop_channel_top_daily_new"
hive_db= "Tmp.tmp_test_table"
Mysqlhelper-s dbname-e "Select Id,shop_id,plat,first_channel,second_channel,pv,uv,gmv,amount,paid_uv,paid_order, DT from $db where dt = ' $yesday ' "> $tmp _channel_hive_file
#打印列写入文件
Awk-f "\ T" ' {for (i=1;i<nf;i++) {printf ("%s\t", $i);} printf ("%s\n", $NF)} ' $tmp _channel_hive_file > $tmp _channel_hive_file_new
Local file Import
HIVE-E "Load data local inpath ' ${tmp_channel_hive_file_new} ' overwrite into table $hive _db PARTITION (dt= ' $yesday ')"
Method 2, you can read the insert directly from the Hive table table
HIVE-E "Insert Overwrite table tmp.tmp_test_table PARTITION (dt= ' $yesday ')
Select Id,shop_id,plat,first_channel,second_channel,pv,uv,gmv,amount,paid_uv,paid_order,dt from hive_table where DT = ' $yesday '
"
To see if the write was successful
Hadoop fs-ls/user/hive/warehouse/hive_table/dt=2016-01*
Or
Show Partitions hive_table
Two ways to write hive db