Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

How can I store sqoop query "select(*) from anytable" results into hdfs?

avatar
Rising Star

I want to run sqoop query to table count records and save this result into any file locally or in hdfs but I can not.

I run this query:-

sqoop eval --connect hostname/db --username user --password password --query 'select count(*) from tablename' --target-dir /sandbox/test

I am getting error:-

Running Sqoop version: 1.4.6.2.3.0.0-2557 (Sqoop:92) 2016-03-28 11:57:55,725 WARN - [main:] ~ Setting your password on the command-line is insecure. Consider using -P instead.

(BaseSqoopTool:1021) 2016-03-28 11:57:55,725 ERROR - [main:] ~ Error parsing arguments for eval: (BaseSqoopTool:303) 2016-03-28 11:57:55,725 ERROR - [main:] ~ Unrecognized argument: --target-dir (BaseSqoopTool:306) 2016-03-28 11:57:55,725 ERROR - [main:] ~ Unrecognized argument: /sandbox/test (BaseSqoopTool:306)

1 ACCEPTED SOLUTION

avatar
Super Guru

Please try below command, its working fine on my cluster.

sqoop import --connect jdbc:mysql://hostname/classicmodels --username root --password xxx --query 'select count(*) as cnt from customers where $CONDITIONS' --m 1 --target-dir /tmp/count1 --driver com.mysql.jdbc.Driver

View solution in original post

3 REPLIES 3

avatar
Super Guru

Please try below command, its working fine on my cluster.

sqoop import --connect jdbc:mysql://hostname/classicmodels --username root --password xxx --query 'select count(*) as cnt from customers where $CONDITIONS' --m 1 --target-dir /tmp/count1 --driver com.mysql.jdbc.Driver

avatar
Rising Star

Thank you so much ! It is working now

you are the man !

avatar
Super Guru

@mike pal

Thanks Mike for confirming, would be great if you can click on best answer 🙂