gpt4 book ai didi

java - 如何将表导入本地文件系统?

转载 作者:行者123 更新时间:2023-11-30 10:32:42 24 4
gpt4 key购买 nike

我正在尝试从配置单元中的表导出结果并使用此命令:

bline --hiveconf hive.mapred.mode=nonstrict --outputformat=csv2 -e "select * from db.table;">~/table.csv

(bline is an alias for beeline -u address + some options)

查询完成但随后给了我

error java.lang.OutOfMemoryError: GC overhead limit exceeded

我导出表是否正确,或者是否有更好的方法在 Hive 中导出表?

最佳答案

由于您的表是以文本格式存储的,您可以简单地使用get/getmerge 将文件从 HDFS 复制到本地文件系统


演示

hive

create table mytable (i int,s string,d date);

insert into mytable values
(1,'hello','2017-03-01')
,(2,'world','2017-03-02')
;

select * from mytable
;

mytable.i mytable.s mytable.d
1 hello 2017-03-01
2 world 2017-03-02

show create table mytable;

CREATE TABLE `mytable`(
`i` int,
`s` string,
`d` date)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'hdfs://localhost:8020/user/hive/warehouse/mytable'
.
.
.

狂欢

hdfs dfs -getmerge /user/hive/warehouse/mytable mytable.txt

cat mytable.txt

1hello2017-03-01
2world2017-03-02

附言列之间有一个看不见的分隔符,字符 SOH,ascii 值为 1。

<mytable.txt tr $'\x01' ','
1,hello,2017-03-01
2,world,2017-03-02

关于java - 如何将表导入本地文件系统?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42561609/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com