![](/img/trans.png)
[英]Can I just substitute “hive” with “meld_beeline” while executing hql files in CLI
[英]Export hql output to csv in beeline
我正在嘗試使用以下命令將我的 hql output 導出到直線中的 csv:
beeline -u "jdbc:hive2://****/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2"?tez.queue.name=devices-jobs --outputformat=csv2 -e "use schema_name; select * from table_name where open_time_new>= '2020-07-13' and open_time_new < '2020-07-22'" > filename.csv
問題是表中的某些列值包含逗號,它將同一列的數據推送到下一個列值。 例如:
| abcd | as per data,outage fault,xxxx.
| xyz |as per the source,ghfg,hjhjg.
以上數據將保存為 4 列而不是 2 列。需要幫助!
嘗試使用本地目錄的方法:
insert overwrite local directory '/tmp/local_csv_report'
row format delimited fields terminated by "," escaped by '\\'
select *
from table_name
where open_time_new >= '2020-07-13'
and open_time_new < '2020-07-22'
這將在您的本地/tmp/local_csv_report
目錄下創建幾個 csv 文件,因此之后使用簡單的cat
會將結果合並到一個文件中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.