Support Questions

Find answers, ask questions, and share your expertise

Hive Partition table by a computed column


I have a large csv file which has the data for my hive table. For that, I first created an external table (table1) pointing to the file location and created an ORC table (table2) from table1.

I want table2 to be partitioned on the value date_key DIV 10000000000. For that, I wrote the following script.

## to create the orc table:
CREATE TABLE table1 ( key1 type1, key2 type2..... keyn typen) PARTITIONED BY (date_key DIV 10000000000 int) STORED AS ORC tblproperties(........);

INSERT OVERWRITE TABLE table_name PARTITION (date_key DIV 10000000000) SELECT * FROM table_2; 

I am getting an error:

FAILED: ParseException line 12:25 cannot recognize input near 'DIV' '10000000000' 'int' in column type

Is what I am doing the right thing to do? Is there a different/better way of accomplishing this. Thanks in advance!


Hi @Sree Kupp

I think its a duplicate question .

Follow the below and delete any one of your questions.

CREATE TABLE table_name ( key1 type1, key2 type2..... keyn typen) PARTITIONED BY (date_key int) STORED AS ORC;

insert into table table_name partition(date_key) select * from table_nam