I need to add parameters in several locations in a long query. I want to use parameters because I need to run the query multiple times with different values substituted in. This is very cumbersome because I need to replace the text in all locations whenever I need to change my filter criteria. Is there a way to set a variable in Impala via HUE?
Initial research indicates that this is possible when working with the impala-shell but for HUE, I've found nothing.
You can make use of the –var=variable_name option in the impala-shell command line option to pass the value. And refer that variable inside SQL script by using statement like ${var:variable_name}. The Impala will resolve the variable in run-time and execute the script by passing actual value.
Hue interface − You can process Impala queries using the Hue browser. In the Hue browser, you have Impala query editor where you can type and execute the impala queries. To access this editor, first of all, you need to logging to the Hue browser.
Note: Use CTRL/Cmd + ENTER to execute queries.
You can set variables in Impala via HUE as you can see in the following picture
You can also use this script. Here type of variables int and date. Also can define a default value.
SELECT id, fullname, birthdate
FROM db.scientists
WHERE id <= ${id=2}
AND to_date(birthdate) BETWEEN '${mindate=1900-01-01}' AND '${maxdate=2000-01-01}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With