Support Questions

Find answers, ask questions, and share your expertise
Celebrating as our community reaches 100,000 members! Thank you!

Is there a way to execute free form query from a file in sqoop?

New Contributor

Have executed a similar kind of sqoop command as shown below. The free form query mentioned below, I wanted to keep it in a file and run the sqoop command since my real time queries are quite complex and bigger.

Wanted to know, Is there a way to keep the query in a file and execute the sqoop command which will refer the free form query inside the file and execute? like we do for --password-file case. Thanks in advance.

<code>sqoop  import --connect "jdbc:mysql://<localhost>:port" --username "admin" --password-file "<passwordfile>" --query "select * from employee" --split-by employee_id --target-dir "<target directory>" --incremental append --check-column employee_id --last-value 0 --fields-terminated-by "|"


Hello @Nandan B R!
Maybe the sqoop options work in this case, but, I didn't test it.

Another way would be to use shell variables and create a script which replaces the --query value by $variable. Or you can try the sqoop 2 using the JDBC Conn

Hope this helps!