我有一个 oozie 作业,它有一个 shell 操作。 首先,shell 操作以编程方式查找存储在 hdfs 上的某些 sql 脚本文件。 然后尝试在 impala 上运行每个 sql 脚本。
由于事先不知道我要运行的 sql 脚本列表,因此不能作为 <file>
传递给 oozie 操作参数,有没有办法运行 impala-shell 并给它一个 hdfs 路径而不是 linux 路径?
最佳答案
Impala shell 可以接受来自 STDIN 的查询文本。如所述here , 选项 -f
-f query_file or --query_file=query_file
query_file=path_to_query_file
Passes a SQL query from a file. Multiple statements must be semicolon (;) delimited. In Impala 2.3 and higher, you can specify a filename of - to represent standard input. This feature makes it convenient to use impala-shell as part of a Unix pipeline where SQL statements are generated dynamically by other tools.
所以在你的情况下,你的 shell 脚本可以简单地做一些像
$ hdfs dfs -cat <hdfs_file_name> | impala-shell -i <impala_daemon> -f -
关于shell - 将 hdfs 上的脚本文件传递给 impala-shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57374651/