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.

Sqoop Import - Import data year by year - hive table

Sqoop Import - Import data year by year - hive table

New Contributor

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

Re: Sqoop Import - Import data year by year - hive table

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  ......
Don't have an account?
Coming from Hortonworks? Activate your account here