hive command in bash script won't load file into table

∥☆過路亽.° 提交于 2019-12-04 05:49:54

问题


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:


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



来源:https://stackoverflow.com/questions/26663858/hive-command-in-bash-script-wont-load-file-into-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!