问题
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”
回答1:
No, you can specify a file of sql statements with -f
, but it does not take a file of parameters. See the impala-shell documentation for more details:
http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/impala_impala_shell.html
回答2:
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
来源:https://stackoverflow.com/questions/28419361/is-there-any-way-to-run-impala-shell-with-sql-script-with-parameters