Djeah
Djeah

Reputation: 360

Can a hive script be run from another hive script?

I have created two hive scripts script1.hql and script2.hql.

Is it possible to run the script script2.hql from script1.hql?

I read about using the source command, but could not get around about its use. Any pointers/ref docs will be appreciated..

Upvotes: 2

Views: 1972

Answers (2)

Sateesh Telaprolu
Sateesh Telaprolu

Reputation: 150

Try using command and see if you can execute

hive -f /home/user/sample.sql

Upvotes: -2

leftjoin
leftjoin

Reputation: 38290

Use source <filepath> command:

source /tmp/script2.hql; --inside script1

The docs are here: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Cli

Hive will include text of /tmp/script2.hql and execute it in the same context, so all variables defined for main script will be accessible script2 commands.

source command looks for local path (not HDFS). Copy file to local directory before executing.

Upvotes: 4

Related Questions