How To : Use Macros when submitting commands through Commands API

Description:

Hive has a variable substitution feature. The functionality is very similar to macros in QDS. Historically Macros is associated with Scheduler. Macros in analyze work in a similar fashion. 

Generally, queries use variables this way:

SET start='2016-03-06 00:00:00';
SET end='2016-03-13 23:59:59';
.
.
BETWEEN $

{hiveconf:start}

AND $

{hiveconf:end}

We'll need to find a suitable alternative to use them through command line.

How To:

Use macros as shown below:

curl -i -X POST -H "X-AUTH-TOKEN: $AUTH_TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{
"query":" select ... between $start$ and $end$;", "command_type": "HiveCommand"
"macros":"[{\"start\":\"\'2016-03-06 00:00:00\'\"}, {\"end\":\"\'2016-03-13 23:59:59\'\}]"}' \
"https://api.qubole.com/api/${V}/commands"

 

Have more questions? Submit a request

Comments

Powered by Zendesk