Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a variable in an Impala query using HUE?

Tags:

impala

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.

like image 882
OTM Avatar asked Jun 08 '20 20:06

OTM


People also ask

How do you pass parameters in Impala query?

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.

What is hue in Impala?

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.

How do you run a query in Hue Impala?

Note: Use CTRL/Cmd + ENTER to execute queries.


2 Answers

You can set variables in Impala via HUE as you can see in the following picture

enter image description here

like image 85
Chema Avatar answered Dec 19 '22 22:12

Chema


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}'   

enter image description here

like image 38
myilmaz Avatar answered Dec 19 '22 22:12

myilmaz