Neeraj Thoota
Neeraj Thoota

Reputation: 21

Run a hive script stored in a HDFS location

I'm trying to run a hive script (.hql file) stored in HDFS location (hdfs://nameservice1/user/neeraj) but I'm not able to find the correct command to execute it. Is there a way to run it directly from HDFS location instead of moving it to my /home/ location?

Upvotes: 2

Views: 2668

Answers (1)

David דודו Markovitz
David דודו Markovitz

Reputation: 44921

hive -f <(hdfs dfs -cat /tmp/my_script.sql)

Demo

cat>my_script.sql
select 1+1 as result;

hdfs dfs -put my_script.sql /tmp

hive -f <(hdfs dfs -cat /tmp/my_script.sql)

Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
hive> select 1+1 as result;
OK
2

Upvotes: 3

Related Questions