A. Pathan A. Pathan - 6 months ago 60
Linux Question

executing hive load command using hive -e '<hive command>'

I am trying to execute hive command using java code. My hive is installed on linux virtual machine and the java code is on a remote windows machine which acts as client. I am able to successfully call the hive commands like:

hive -e 'Select * from mytable;'

But when I tried using load command with syntax as :

hive -e 'LOAD DATA LOCAL INPATH '/home/mapr/file.csv' INTO TABLE mytable;'

It throws me an error saying "FAILED: ParseException line 1:23 mismatched input '/' expecting StringLiteral near 'INPATH' in load statement"

This seems to be a syntax error near the file path probable an escape character issue, because I am able to execute "Select * from mytable" without error.
Can anyone help me with the syntax for hive load command using hive -e ?


By looking at your error message, it is clear that you are using single quote escape character twice and massing up your hive command.

So now use single and double quote to distinguish escape character and it will work.

New hive statement can be given below:

hive -e 'LOAD DATA LOCAL INPATH "/home/mapr/file.csv" INTO TABLE mytable;'

Hope this help you!!!