hive报错之Malformed ORC file Invalid postscript.

Caused by: java.io.IOException: Malformed ORC file
将本地文件的数据加载到hive的ORC格式表时,出现类似于以上报错

原因:
ORC格式是列式存储的表,不能直接从本地文件导入数据,只有当数据源表也是ORC格式存储时,才可以直接加载,否则会出现上述报错。

解决办法:
要么将数据源表改为以ORC格式存储的表,要么新建一个以textfile格式的临时表先将源文件数据加载到该表,然后在从textfile表中insert数据到ORC目标表中。

转自---------------------
作者:蜗牛fly 来源:CSDN
原文:https://blog.csdn.net/qq_33536353/article/details/50970535

个人拓展补充:
流程1:直接通过insert into语句从另外一张orc表中导入数据到此表:insert into tableA select * from tableB;
流程2:创建一个testfile普通的表------导入本地目录下文件内容-----创建orc类型的表----将普通表的记录copy到orc表中
流程2的方法如下:
1.首先创建普通类型的表(一般是Text)

create table tablename_testA(
    id      int,
	name    string
)
row format delimited
fields terminated by ','
stored as textfile;  /*存储类型*/

2.导入数据到普通表

load data local inpath '/tmp/test/table/data.txt' overwrite into table tablename_testA;

3.新建orc存储类型的表

create table tablename_testB(
    id      int,
	name    string
)
row format delimited
fields terminated by ','
stored as orc;

4.插入orc数据

insert into tablename_testB select * from tablename_testA;

5.查看表的orc位置

show create table tablename_testB;

返回信息中LOCATION的值即为orc位置信息

  1. 查看表中内容:hadoop fs -ls 路径
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值