0

I am writing a bash script that - among other things - has to create a hive table and load a csv file (whose name is not known a priori) into that table. I have exported the name of the file foo.csv into the environment variable myfile and have tried the command

hive --hiveconf mf=$myfile -e 'set mf; set hiveconf:mf; load data local inpath ${hiveconf:mf} into table mytable'

It returns the error

FAILED: ParseException line 1:23 mismatched input 'foo' expecting StringLiteral near 'inpath' in load statement

I already tried using the absolute path to the file and it won't work either: if the path is /mypath/foo.csv the error will be

FAILED: ParseException line 1:23 mismatched input '/' expecting StringLiteral near 'inpath' in load statement

Even trying to directly put the file name like this

hive -e 'load data local inpath foo.csv into table mytable'

doesn't work at all, and the thrown error is the same as before.

Does anybody have any idea on what is wrong with these commands? I could really appreciate some help, thanks.

1 Answer 1

1

Filename should be placed inside '' :

load data local inpath 'foo.csv' into table mytable

In your script you should probably escape these symbols so you won't get another parse exception.

Also, look at Language Manual on loading

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.