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?
Run Sqoop Command In order to run this command, open the terminal on your computer and paste above sqoop import command into it and press enter. When you do that, Sqoop import will start importing specific columns from MySQL table and store them into flat files in HDFS.
Apache Sqoop can import the result set of the arbitrary SQL query. Rather than using the arguments –table, –columns and –where, we can use –query argument for specifying a SQL statement. Note: While importing the table via the free-form query, we have to specify the destination directory with the –target-dir argument.
Free-form Query Imports. Sqoop can also import the result set of an arbitrary SQL query. Instead of using the --table , --columns and --where arguments, you can specify a SQL statement with the --query argument. When importing a free-form query, you must specify a destination directory with --target-dir .
Sqoop performs highly efficient data transfers by inheriting Hadoop's parallelism. To help Sqoop split your query into multiple chunks that can be transferred in parallel, you need to include the $CONDITIONS placeholder in the where clause of your query.
You have to add AND \$CONDITIONS
--query "select * from reason where id>20 AND \$CONDITIONS"
Please refer Sqoop documentation .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With