Hadoop – ny way to run impala shell with sql script with parameters?


Is there any way to run impala shell with SQL script with parameters?

For example:

impala-shell -f /home/john/sql/load.sql /dir1/dir2/dir3/data_file

I got errors:

Error, could not parse arguments "-f /home/john/sql/load.sql /dir1/dir2/dir3/data_file”

Best Solution

This feature is available in CDH 5.7 / Impala 2.5 and higher.

The --var option lets you pass substitution variables to the statements that are executed by that impala-shell session, for example the statements in a script file processed by the -f option. You encode the substitution variable on the command line using the notation --var=variable_name=value. Within a SQL statement, you substitute the value by using the notation ${var:variable_name}.

See more details directly in the documentation : https://www.cloudera.com/documentation/enterprise/latest/topics/impala_set.html

Related Question