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

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-03 08:59:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!