Giorgio
Giorgio

Reputation: 1093

dynamic partition insert Hive

I have a problem inserting records into a table called exam_51_final using dynamic partitioning, this is my scenario:

create table exam_51_temp(
order_id int,
order_date bigint,
order_customer_id int,
order_status string)
stored as avro
TBLPROPERTIES ('avro.schema.url'='/user/ccp/20180827/51/avro.schema');

When I print the output I have:

68878   1404770400000   6753    COMPLETE    COMPLETE
68879   1404856800000   778     COMPLETE    COMPLETE
68880   1405202400000   1117    COMPLETE    COMPLETE

Then I have my table exam_51_final created like this:

create table exam_51_final(
order_id int,
order_date bigint,
order_customer_id int,
order_status string)
partitioned by (order_month string)
stored as avro;

I activate dynamic partitioning using:

set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;

Then I finally try to insert records from exam_51_temp to exam_51_final simulating a dummy dynamic partition column in two ways:

1)

insert into table exam_51_final partition(order_m) 
select order_id,order_date,order_customer_id,order_status,(case
when order_id < 1000 then '2018-05'
when order_id >= 1000 then '2018-06'
end) order_m
from exam_51_temp;

2)

insert into table exam_51_final partition(order_m) 
select order_id,order_date,order_customer_id,order_status, order_status as order_m
from exam_51_temp;

The select query itself is going well, but I always receive the following error message:

FAILED: SemanticException Partition spec {order_m=null} contains non-partition columns

Where is my error?

Upvotes: 0

Views: 1027

Answers (1)

Giorgio
Giorgio

Reputation: 1093

Uff...I found the solution: The partition column name must be order_month, if I put a differente column name I receive the error above.

Upvotes: 1

Related Questions