aiman
aiman

Reputation: 1103

Hive External Table

I am trying to import data from Oracle to Hive using sqoop.
I used the command below once, now I want to overwrite the existing data with new data (Daily Action).
I ran this command again.

sqoop import --connect jdbc:oracle:thin:@UK01WRS6014:2184:WWSYOIT1 
--username HIVE --password hive --table OIDS.ALLOCATION_SESSION_DIMN 
--hive-overwrite --hive-database OI_DB --hive-table ALLOCATION_SESSION_DIMN  

But I am getting an error File already exists:

14/10/14 07:43:59 ERROR security.UserGroupInformation: 
PriviledgedActionException as:axchat 
(auth:SIMPLE) cause:org.apache.hadoop.mapred.FileAlreadyExistsException: 
Output directory 
hdfs://uslibeiadg004.aceina.com:8020/user/axchat/OIDS.ALLOCATION_SESSION_DIMN 
already exists

The tables that I created in hive were all external tables. Like mapreduce, do we have to delete that file everytime we execute the same command ?

Any help would be highly appreciated.

Upvotes: 1

Views: 1243

Answers (1)

davek
davek

Reputation: 22895

When you delete from an EXTERNAL table you only delete objects in the Hive metastore: you don't delete the files over which that table is superimposed. A non-external table belongs soley to Hive and, when deleted, will result in metastore- AND HDFS-data being removed.

So you can either try deleting the HDFS data explicitly, or define the table as being internal to hive.

Upvotes: 1

Related Questions