Support Questions
Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Innovation Accelerator group hub.

Sqoop Import - Import data year by year - hive table

Explorer

I have a table with 10years of records. I have to import the table with 1year(01-Jan-2010 to 31-Dec-2010) records every time. How to pass these date ranges as arguments to the sqoop shell script.

1 REPLY 1

Expert Contributor

@Nikhil Vemula

Have you been able to get this working? If you have received the info, you can use something like the below command to get the data based on the date range

#!/bin/sh
mindate=$1
maxdate=$2
querytorun="select * from <TABLENAME> where date>= $mindate and date<= $maxdate"
querytorun+=" and \$CONDITIONS"
sqoop import  --connect jdbc:mysql://<DPIPADDRESS>/<DBNAME> --username <USERNAME> --password <PASSWORD> --query "$querytorun"  --split-by "<SPLITBYKEY>" --delete-target-dir  ......