3
votes

I'm trying to load a file locally into Hive by running this command:

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

which gives me the error:

SemanticException [Error 10062]: Need to specify partition columns because the destination table is partitioned (state=42000,code=10062)

An answer I found suggests creating an intermediate table then letting dynamic partitioning kick in to load into a partitioned table.

I've created a table that matches the data and truncated it:

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

Then loaded the data using:

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

How do I 'kick in' dynamic partitioning?

1

1 Answers

5
votes
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;