从hdfs目录中的beeline转储数据

ilmyapht  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(443)

我正在编写一个bash脚本,将动态sql查询导出到hdfs目录下的hql文件中。
sql_v=选择“从用户选项卡的列中创建表名…”
直线-u“$sql\u v”>本地路径
sqlv变量将存储动态create table命令,我想将其存储在hdfs目录中的hql文件中。如果我运行以上两个步骤,它运行得很好,因为我在本地路径中存储数据,但不是传递本地\u路径,而是要在hdfs目录中存储sql。有没有一种方法可以传递hdfs路径而不是下面的本地\u路径,但这不起作用。我可以使用任何其他命令而不是直线来实现这一点吗?
beeline-u“$sql v”| hdfs dfs-appendtofile-

cld4siwp

cld4siwp1#

如果目标是将beeline的输出写入hdfs文件,那么下面的选项应该可以很好地工作,因为这两个命令都将beeline的标准输出作为输入通过管道传输到hadoop命令,该输入由(-)识别。

beeline -u beeline_connection_string .... -e "$sql_v" | hadoop fs -put - /user/userid/file.hql

beeline -u beeline_connection_string .... -e "$sql_v" | hadoop fs -appendToFile - /user/userid/file.hql

注:1。根据你的问题和评论,我们有点不清楚为什么你不能使用@cricket\u007给出的建议,以及为什么要特别选择直线。

echo "$sql_v" > file.hql
hadoop fs -put file.hql /user/userid/file.hql

beeline -u beeline_connection_string .... -e "$sql_v" > file.hql 
hadoop fs -appendToFile file.hql /user/userid/file.hql

beeline -u beeline_connection_string .... -e "$sql_v" > file.hql 
hadoop fs -put file.hql /user/userid/file.hql

如果使用oozie shell action来运行包含sqlv和beeline命令的bash脚本,beeline需要出现在shell action将运行的节点中,否则将面临beeline not found错误。请参阅:未找到直线命令错误

相关问题