Impala - how to set a variable in a query?

sellarafaeli picture sellarafaeli · Nov 26, 2014 · Viewed 17.8k times · Source

How can I set a variable in an Impala query?

In SQL:

select * from users where id=(@id:=123)

In Impala:

impala-shell> ?

Impala version is v2.0.0. Any suggestions will be appreciated. Thanks!

Answer

Yilei picture Yilei · Aug 18, 2016
impala-shell> set var:id=123;select * from users where id=${VAR:id};

 

This variable can also be passed from command-line using --var

impala-shell --var id=123
impala-shell> select * from users where id=${VAR:id};