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.

Can I create Primary Key in Hive table? I saw in TBLPROPERTIES you can mention "PRIMARY KEY"="col_name", what it actually does?

Solved Go to solution

Can I create Primary Key in Hive table? I saw in TBLPROPERTIES you can mention "PRIMARY KEY"="col_name", what it actually does?

New Contributor
 
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Can I create Primary Key in Hive table? I saw in TBLPROPERTIES you can mention "PRIMARY KEY"="col_name", what it actually does?

@Abdus Sagir Mollah the designation of primary key is simply metadata describing the column. It doesn't apply any referential constraints.

3 REPLIES 3

Re: Can I create Primary Key in Hive table? I saw in TBLPROPERTIES you can mention "PRIMARY KEY"="col_name", what it actually does?

@Abdus Sagir Mollah the designation of primary key is simply metadata describing the column. It doesn't apply any referential constraints.

Re: Can I create Primary Key in Hive table? I saw in TBLPROPERTIES you can mention "PRIMARY KEY"="col_name", what it actually does?

@Abdus Sagir Mollah

Primary keys can also be useful for bucketing (i.e. paritioning of data) especially if you are trying to leverage the ACID capabilities of Hive.

Quote from the below blog:

  • Once an hour, a set of inserts and updates (up to 500k rows) for various dimension tables (eg. customer, inventory, stores) needs to be processed. The dimension tables have primary keys and are typically bucketed and sorted on those keys.

Entire blog: http://hortonworks.com/blog/adding-acid-to-apache-hive/

Re: Can I create Primary Key in Hive table? I saw in TBLPROPERTIES you can mention "PRIMARY KEY"="col_name", what it actually does?

@Andrew Watson - The ACID properties have been taken back by the community. It is not recommended for customer use currently.