Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Unable to use HIVE QL function in sqoop import

Highlighted

Unable to use HIVE QL function in sqoop import

Hi

I am trying to create a new hive table from an existing table and using the select query as mentioned below. However, the sqoop import is failing with the error

-bash: syntax error near unexpected token `('

Please can some one help?

sqoop import --query SELECT emp_no,salary,from_date,Date_SUB(to_date,1) as new FROM salaries --table salaries_parquet --as-parquetfile --hive-import

Thanks in advance

Regards

Naveen

4 REPLIES 4

Re: Unable to use HIVE QL function in sqoop import

@Naveen Keshava-where are you importing from? Can you post the full command you have been using.!

Re: Unable to use HIVE QL function in sqoop import

@Naveen Keshava

When using freeform queries within sqoop command then it should be as below:

sqoop import --query 'SELECT emp_no,salary,from_date,Date_SUB(to_date,1) as new FROM salaries where $CONDITIONS' --table salaries_parquet --as-parquetfile --hive-import

Doc link.

Re: Unable to use HIVE QL function in sqoop import

@Sindhu Thank you for your response. That helped. after including the quotes, I had a few other errors on the lines if required parameters missing. so i recreated the command as below,

sqoop import --query 'SELECT emp_no,salary,from_date,Date_SUB(to_date,1) as new FROM salaries' --as-parquetfile --hive-import --hive-table salaries_parquet --target-dir /user/user1/ --split-by emp_no --connect jdbc:mysql://ip/employees --username something --password something

but i got the error message without much info other than NullPointerException. please could you advice me, or perhaps let me know where i can find additional logs for investigation.

17/06/04 04:38:33 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.NullPointerException java.lang.NullPointerException at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:97) at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:478) at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:605) at org.apache.sqoop.Sqoop.run(Sqoop.java:148) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76) at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:184) at org.apache.sqoop.Sqoop.runTool(Sqoop.java:226) at org.apache.sqoop.Sqoop.runTool(Sqoop.java:235) at org.apache.sqoop.Sqoop.main(Sqoop.java:244)

Re: Unable to use HIVE QL function in sqoop import

New Contributor

Please use where $CONDITIONS in ur query