043.hive-导出数据hive-csv

 

复制代码
1.
su hdfs
cd ~ 

2.
hive -e " set hive.cli.print.header=true;                
USE saas; SELECT CONCAT_WS(',',                          
cast( nvl(order_id              ,0) as string)             
,cast( nvl(total_amount          ,0.00) as string)       
,cast( nvl(dinner_count          ,0) as string)          
,cast( nvl(latitude              ,0.00) as string)       
,cast( nvl(longitude             ,0.00) as string)       
,cast( nvl(has_invoice           ,0) as string)          
,cast( nvl(invoice_type          ,0) as string)          
,cast( nvl(invoice_title         ,'') as string)         
,cast( nvl(invoice_taxpayer      ,'') as string)         
,cast( nvl(description           ,'') as string)         
,cast( nvl(place_time,cast('1000-01-01 00:00:00' as timestamp)) as string)
,cast( nvl(delivery_time,cast('1000-01-01 00:00:00' as timestamp)) as string)        
,cast( nvl(order_type            ,'') as string)         
,cast( nvl(status                ,'') as string)         
,cast( nvl(create_time,cast('1000-01-01 00:00:00' as timestamp)) as string)        
,cast( nvl(dt                    ,0) as string)            
,cast( nvl(data_source           ,'') as string))           
from  order_di 
where shop_code = '76729050'  ; " | sed 's/[\t]/,/g' >  one_shop.csv

3.压缩 
zip -r  one_shop.zip   one_shop.csv

4.sz   one_shop.zip  

5.csv 注意科学计数法的转换 
 
复制代码

 

posted @   star521  阅读(221)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
历史上的今天:
2021-07-26 033.PGSQL-psql-登录时执行sql命令和sql文件,传递参数
2021-07-26 032.PGSQL-pgsql的except-除了, intersect-交集
2021-07-26 031.PGSQL-psql-导入导出数据COPY 和\copy命令
点击右上角即可分享
微信分享提示