Search code examples
sqoop

Sqoop import having SQL query with where clause


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?


Solution

  • You have to add AND \$CONDITIONS

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

    Please refer Sqoop documentation .