hive内部表导入数据报错:
建表语句:
create table test_udf2_orc(
class_name string,
method_name string,
col1 int,
col2 int
)
row format delimited
fields terminated by ','
stored as orc;
数据导入语句:
load data local inpath '/opt/module/hive-3.1.3/export/servers/hivedatas/test_udf2' overwrite into table test_udf2_orc;
从某些文章上获得的信息是:
纯属误人子弟,博主是谁我就不说了。大家注意辨别:实践是检验真理的唯一标准。但是本人实测,这种说法是不对的。
图片或标题上的翻译是:
所以只是表存储格式的问题,而不是不能使用load data导致的。因为在导入数据时,被导入数据格式是TEXTFILE格式,最终导致此问题.
解决方法:
方式一:表的存储格式定义为textfile
1、建表
create table test_udf2_textfile(
class_name string,
method_name string,
col1 int,
col2 int
)
row format delimited
fields terminated by ','
stored as textfile;
2、导入数据
load data local inpath '/opt/module/hive-3.1.3/export/servers/hivedatas/test_udf2' overwrite into table test_udf2_textfile;
3、验证数据:
方式二:定义一个textfile的外部表,如果不想用外部表
1、创建外部表
2、insert overwrite table 内部表 select * from 外部表。
有问题,欢迎大家指正,大家一起学习,向上生长,共同进步。