I need inputs for below office project where I need to move data from DB2 to HDFS using Sqoop.
We have more than 1 Billion rows in DB2 tables and planning to move that to hdfs and use hive table to run analytics.
Records get inserted and updated daily on these DB2 tables. So planning to move the data in two steps using sqoop. The first step to load existing data and then setup daily sqoop import to move previous day data.
I want to store this data with partitions by date. Data existence is top priority, so I am thinking External hive table would be right option. Please provide inputs on below query.
In DB2 table, I am having a date column. When I move to hdfs location, I want to store them as date partitions in external table. Looks like there are limitations in using external hive table partitions.
If I create the external hive table first with partitions by date like below example
create external tables sample (ID string, name string) partitioned by (date string)
location "/sampledata/;
a) how to sqoop import existing data to hdfs in different date folders under /sampledata ? I have 3 years of data in DB2.
b) how to sqoop incremental data daily to /sampledata under few folder for that date?
c) Do you recommend going for internal table instead?
I think we can achieve this using below command by passing currentdatefolder value as input to this command.
sqoop import "" --username abc -password abc --table source_table --target-dir /sampledata/currentdatefolder -m1 --check-column modified_date --incremental lastmodified --last-value {last_import_date}
But after that, do we need to alter table to add this new folder to partitions?
ALTER TABLE sample ADD PARTITION (date="currentdatefolder") LOCATION "/sampledata/currentdatefolder";