我使用 Hive 创建了一个表 我想根据位置对数据进行分区
create table student(
id bigint
,name string
,location string
, course array<string>)
ROW FORMAT DELIMiTED fields terminated by 't'
collection items terminated by ','
stored as textfile;
和数据像
100 student1 ongole java,.net,hadoop
101 student2 hyderabad .net,hadoop
102 student3 vizag java,hadoop
103 student4 ongole .net,hadoop
104 student5 vizag java,.net
105 student6 ongole java,.net,hadoop
106 student7 neollre .net,hadoop
创建分区表:
create table student_partition(
id bigint
,name string
,course array<string>)
PARTITIONED BY (address string)
ROW FORMAT DELIMiTED fields terminated by 't'
collection items terminated by ','
stored as textfile;
插入覆盖表student_partition分区(地址( 选择 * 来自学生;
我正在尝试根据位置对数据进行分区,但它显示以下错误:
失败:语义异常 [错误 10044]:第 1:23 行无法插入 目标表,因为列号/类型是不同的"地址": 无法将第 2 列从字符串转换为数组。
请任何人帮助我。
源和目标的列应该匹配
选项 1:将源调整到目标。分区列排在最后
insert into student_partition partition (address)
select id,name,course,location
from student
;
选项 2:将目标调整为源
insert into student_partition partition (address) (id,name,address,course)
select *
from student
;
附言你可能需要这个 -
set hive.exec.dynamic.partition.mode=nonstrict
;