0

To my understanding, the following will result in passing a global Hive variable:

   hive -hiveconf DATE='01/01/2000' -f test_script.hql

That can be called with

   SELECT * FROM DATETABLE WHERE DATE = ${hiveconf:DATE}

And I know that local variables can be defined in the script and called by doing:

   set DATE='01/01/2000'
   SELECT * FROM DATETABLE WHERE DATE = ${DATE}

But say one wanted to submit many jobs with local parameters set for each script, how can we pass them from the command line?

The emphasis is avoiding one script picking up the hiveconf:DATE set by another script that was submitted in quick succession.

EDIT:

I guess this could work, creating a shell script and passing variables to the shell script and then passing those to the individual queries:

    #!/bin/bash

    FIRST_QUERY = "SELECT * FROM DATETABLE WHERE DATE = '$DATE'"

    hive -e "$FIRST_QUERY"

But this seems inefficient, I would still want to know if the option above is possible.

1 Answer 1

1

I found the option -define here:

hive -e 'SELECT * FROM DATETABLE WHERE DATE = ${DATE}' -define DATE='01/01/2000'
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.