Impala - how to set a variable in a query?
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 version 2.0. Any suggestions would be appreciated. Thank you!
There is an open feature request to add support for variable substitution in impala-shell: IMPALA-1067 to mimic a similar Hive function ( hive --hivevar param=60
replaces ${hivevar:param}
within a request with 60
).
Variables that can be used in other SQL contexts (like from a JDBC client) are also not supported 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
impala-shell> set var:id=123;select * from users where id=${VAR:id};
This variable can also be passed from the command line using --var
impala-shell --var id=123
impala-shell> select * from users where id=${VAR:id};
impala-shell -i node.domain:port -B --var"table=metadata" --var="db=transaction" -f "file.sql"
file.sql:
SELECT * FROM $ {var: db}. $ {Var: table} "