HIVE导出数据命令hive -e的使用(导出文件前先删除原文件的内容)

       小白最近在工作中遇到,从hive表中向服务器导出txt文档的问题,之前没有注意到一个问题:

情景一:导入到csv文件

       之前一直是将hive表中的查询结果导入到csv文件中,用下面的语句执行:

每次的csv文件都是覆盖上一次的结果

file_path="/home/chen"
file_name_t="test.csv"
hive -e "set hive.resultset.use.unique.column.names=false;set hive.cli.print.header=true; 
select
      d,
      count(distinct orderid) as ordernum,
      sum(roomnum) as roomnum,
      sum(roomprice)as roomprice
 from table
where d >='${zdt.addDay(-10).format("yyyy-MM-dd")}'
  and d < '${zdt.format("yyyy-MM-dd")}'
group by d
;" >> $file_path/$file_name_t

情景二:导入到txt文件

但是,小白在将上面语句同样的,把导出文件换成txt,就出现了问题,大家可以看下有没有遇到过类似的情况

file_path="/home/chen"
file_name_t="test.txt"
hive -e "set hive.resultset.use.unique.column.names=false;set hive.cli.print.header=true; 
select
      d,
      count(distinct or
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值