8

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.

OTM
  • 186
  • 3
  • 14

2 Answers2

9

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

enter image description here

Chema
  • 2,748
  • 2
  • 13
  • 24
  • This works and it also accommodates multiple values (e.g. - Monopoly','Scrabble) for use with the 'in' operator. Thank you. – OTM Jun 09 '20 at 14:26
  • It was useful and you can upvote, I would appreciate it, thanks. – Chema Jun 09 '20 at 15:00
3

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

Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35
myilmaz
  • 31
  • 3