蜂巢:从蜂巢脚本调用shell命令会引发错误

时间:2018-07-19 12:10:09

标签: shell hive sh

我有一个配置单元脚本,该脚本执行一些DML和一些表,并执行一些shell删除文件。我正在使用hive -f myscript.hql触发脚本。
从脚本中,我需要从本地目录中删除文件。我尝试使用!rm /home/myuser/temp_table_id_*;引发错误:

rm: cannot remove ‘/home/myuser/temp_table_id_*’: No such file or directory
Command failed with exit code = 1

*不起作用。
这是一个示例脚本:

--My HQL File--
INSERT OVERWRITE ....
...
..;
DROP TABLE TEMP_TABLE;
!hadoop fs -rm -r /user/myuser/ext_tables/temp_table;
!rm /home/myuser/temp_table_id_*;

CREATE TABLE NEW_TABLE(
....
...
;

我正在使用以下命令调用脚本:hive -f myscript.hql 脚本运行正常,直到找到行!rm /home/myuser/temp_table_id_*;为止的行:*
当我提供单独的文件名而不是*时,它将起作用。
但我希望使用*

1 个答案:

答案 0 :(得分:0)

尝试

dfs -rm /home/myuser/temp_table_id_*;
HQL中的

。通配符与hive dfs命令配合使用会很好。

来自Hive docs

dfs <dfs command> -Executes a dfs command from the Hive shell.