Support Questions

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

How to execute multiple SQL queries with Sqoop import --query command? Also what is the maximum size of query string?

avatar

How to execute multiple SQL queries with Sqoop import --query command? Also what is the maximum size of query string?

1 ACCEPTED SOLUTION

avatar
Super Collaborator

@Mahendra Dahiya

The sqoop import --query option is intended to process a single statement and there are warnings about using complex queries.

The facility of using free-form query in the current version of Sqoop
is limited to simple queries where there are no ambiguous projections and
no OR conditions in the WHERE clause. Use of complex queries such as
queries that have sub-queries or joins leading to ambiguous projections can
lead to unexpected results.

A few more details are at this URL:

https://sqoop.apache.org/docs/1.4.2/SqoopUserGuide.html#_free_form_query_imports

View solution in original post

4 REPLIES 4

avatar
Super Collaborator

@Mahendra Dahiya

The sqoop import --query option is intended to process a single statement and there are warnings about using complex queries.

The facility of using free-form query in the current version of Sqoop
is limited to simple queries where there are no ambiguous projections and
no OR conditions in the WHERE clause. Use of complex queries such as
queries that have sub-queries or joins leading to ambiguous projections can
lead to unexpected results.

A few more details are at this URL:

https://sqoop.apache.org/docs/1.4.2/SqoopUserGuide.html#_free_form_query_imports

avatar

Thanks Terry. What is the alternate solution to execute multiple sql query ?

avatar
Super Collaborator

You are welcome Mahendra. I think you will have to push the complex query to the database and place those results into a different table and then perform the sqoop command on that table. Best of luck.

avatar
Expert Contributor

How about create views in source databases.