Skip to content
Advertisement

Will the constraints remain after Importing table from RDBMS to HIVE with sqoop?

When we use sqoop import to transfer an RDBMS table to HIVE, will the constraints of the table such as primary key remain ?

i.e. will the column of the table which is the primary key remain as primary key at the HIVE. Will this information be in the Hive metastore ?

Thanks a lot.

Advertisement

Answer

As you can see in the link of the official documentation of Hive QL below, PRIMARY and FOREIGN constraints have been added since Hive version 2.1.0. Hive QL

Hive 2.1.0 Changes

So, I assume that the PRIMARY and FOREIGN Keys constraints will remain when you import your tables to Hive using sqoop.

I tested a sqoop import of MySQL database, and I can see that PRIMARY KEY CONSTRAINT is not maintained during the import.

MySQL Table Format:

Data has been imported from MySQL to Hive with the following command:

When I describe the table in hive, I cannot see the PRIMARY KEY CONSTRAINT

I inserted a new row with same employee number to check if Hive manage PK Constraint. The new row has been added as you can see:

So to conclude: Sqoop does not preserve PK constraint when importing RDBMS data to Hive

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement