在路径文件中加载到分区表

时间:2017-07-20 12:09:27

标签: hadoop hive

我正在尝试通过运行此命令将文件本地加载到Hive中:

LOAD DATA INPATH '/data/work/hive/staging/ExampleData.csv' INTO TABLE tablename;

给了我错误:

  

SemanticException [错误10062]:需要指定分区列   因为目标表已分区(状态= 42000,代码= 10062)

An answer I found建议创建一个中间表,然后让动态分区加载到分区表中。

我创建了一个匹配数据并截断它的表:

create table temptablename as select * from tablename;
truncate table temptablename

然后使用:

加载数据
LOAD DATA INPATH '/data/work/hive/staging/ExampleData.csv' INTO TABLE temptablename;

如何启动'动态分区?

1 个答案:

答案 0 :(得分:3)

1.Load data into temptablename(without partition)
create table temptablename(col1,col2..);
LOAD DATA INPATH '/data/work/hive/staging/ExampleData.csv' INTO TABLE 
temptablename;

now once you have data in intermediate table ,you can kick in dynamic 
partitioning using following command.

2.INSERT into tablename PARTITION(partition_column) select * from 
temptablename;