Impala - how to set a variable in a query?
21,579
Solution 1
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};
Solution 2
There's an open feature request for adding variable substitution support to impala-shell: IMPALA-1067, to mimic Hive's similar feature (hive --hivevar param=60
substitutes ${hivevar:param}
inside a query with 60
).
Variables that you can use in other SQL contexts (e.g. from a JDBC client) are not supported either, and I couldn't even find an open request for it... You might want to open a request for it: https://issues.cloudera.org/browse/IMPALA
Author by
sellarafaeli
Updated on July 09, 2022Comments
-
sellarafaeli almost 2 years
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!