作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从配置单元中的表导出结果并使用此命令:
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/
我是一名优秀的程序员,十分优秀!