配置单元:从配置单元脚本调用shell命令会引发错误

vsnjm48y  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(276)

我有一个配置单元脚本,它执行一些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_*;` 你在诅咒什么 `*` .
当我提供单独的文件名而不是 `*` ,它在工作。
但我想用 `*` .
sc4hvdpw

sc4hvdpw1#

尝试

dfs -rm /home/myuser/temp_table_id_*;

在hql中。通配符可以很好地与配置单元dfs命令配合使用。
来自hive文档

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

相关问题