Sqoop import having SQL query with where clause

Dev picture Dev · Feb 28, 2016 · Viewed 48.1k times · Source
sqoop import --connect jdbc:teradata://192.168.xx.xx/DBS_PORT=1025,DATABASE=ds_tbl_db 
--driver com.teradata.jdbc.TeraDriver 
--username dbc 
--password dbc 
--query 'select * from reason where id>20' 
--hive-import 
--hive-table reason_hive 
--target-dir <hdfs-location> 
-m 1

I got the error:

Query [select * from reason where id>20] must contain '$CONDITIONS' in WHERE clause.

I know there must be a where clause in query for Sqoop.

So, for queries like

select * from reason

I modify it to:

select * from reason WHERE $CONDITIONS

What to do for queries having where clause?

Answer

vinayak_narune picture vinayak_narune · Feb 29, 2016

You have to add AND \$CONDITIONS

--query "select * from reason where id>20 AND \$CONDITIONS"

Please refer Sqoop documentation .