Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Hive Partition table by a computed column

Highlighted

Hive Partition table by a computed column

Explorer

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!

1 REPLY 1

Re: Hive Partition table by a computed column

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

Don't have an account?
Coming from Hortonworks? Activate your account here