3

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?

Keshav Pradeep Ramanath
  • 1,623
  • 4
  • 24
  • 33
Nanor
  • 2,400
  • 6
  • 35
  • 66

1 Answers1

5
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;
user2017
  • 444
  • 1
  • 4
  • 14