hive报错之Malformed ORC fileInvalid postscript.

it2022-05-09  41

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

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

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

转自--------------------- 作者:蜗牛fly 来源: 原文: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位置信息

查看表中内容:hadoop fs -ls 路径

最新回复(0)