- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to store the value of a sqoop eval statement in a variable
- Labels:
-
Apache Hive
-
Apache Sqoop
Created ‎08-14-2018 04:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a requirement where I need to compare the value that exists in a source table i.e. in Teradata vs the data that I am pulling into, the destination table, i.e. Hadoop.
I do know that there is a way to load the value into a textfile in HDFS, but am unable to store the value into a variable.
This is what I have done this far:
MYVAL=$(sqoop eval \ -libjars $LIB_JARS -Dteradata.db.input.job.type=hive \ --connect "jdbc:teradata://XXXXXXx" \ --username XXXXXX \ --password XXXXX \ --query "select count(*) from database_name.table_name | awk'/([0-9]+)/{print $2}');")
var=`env -i hive -S -e "select count(*)from database_name.table_name ;"`
echo $MYVAL
echo $var
Created ‎08-29-2018 07:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sqoop eval with select query basically returns the output of the query on the terminal and storing the same onto a variable is not possible. You can do following:
sqoop eval \ -libjars $LIB_JARS -Dteradata.db.input.job.type=hive \ --connect "jdbc:teradata://XXXXXXx" \ --username XXXXXX \ --password XXXXX \ --query "select count(*) from database_name.table_name 1> sqoop.out 2>sqoop.err
hive -S -e "select count(*)from database_name.table_name ;" 1> hive.out 2>hive.err
The files sqoop.out and hive.out would include some log messages as well which could be grepped and removed.
