我正在尝试将数据从普通表加载到 Hive 分区表。
这是我的正常表语法:
create table x(name string, date1 string);
这是我的新分区表语法:
create table y (name string, date1 string) partitioned by (timestamp1 string);
以下是我如何将数据加载到 y 的方法:
insert into table y PARTITION(SUBSTR(date1,0,2)) select name, date1 from x;
这是我的例外:
FAILED: ParseException line 1:39 missing ) at '(' near ',' in column name
line 1:51 cannot recognize input near '0' ',' '2' in column name
使用动态分区:
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert into table y PARTITION(timestamp1)
select name, date1, SUBSTR(date1,0,2) as timestamp1 from x;