Support Questions
Find answers, ask questions, and share your expertise

enable to create hive table with primary key constraint

Expert Contributor

Hi,

I am using HDP 2.5 in hortonworks sanbox. The HIVE version is 1.2.1. I am trying to create hive table with primary key constraint with below query:

CREATE TABLE pk 
       (id1 int,id2 int,
        name string,
        dept string,
        primary key(id1,id2) 
        disable novalidate) 
        PARTITIONED BY (year string);

while executing this create table query it throws below error:

 ParseException line 1:65 cannot recognize input near 'key' '(' 'id1' in column type

I am not getting what this error and how to resolve it.

Is constraints supported in HIVE 1.2.1 ?

can anyone help me out to resolve this issue ?

Thank You.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: enable to create hive table with primary key constraint

@heta desai

Based on this jira

https://issues.apache.org/jira/browse/HIVE-13290

and the hive docs:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Constraints

This is supported from hive 2.1.0 onwards only.

HTH

*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.

View solution in original post

2 REPLIES 2

Re: enable to create hive table with primary key constraint

@heta desai

Based on this jira

https://issues.apache.org/jira/browse/HIVE-13290

and the hive docs:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Constraints

This is supported from hive 2.1.0 onwards only.

HTH

*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.

View solution in original post

Re: enable to create hive table with primary key constraint

Expert Contributor
@Felix Albani

Thank you.