2017-02-15 173 views
0

我想在hive腳本中運行date命令。它是一個shell命令,我嘗試使用前面的'!'。試過以下內容:hive腳本中的日期shell命令

hive (default)> !date --date="6 months ago"; 
date: extra operand `ago"' 
Try `date --help' for more information. 
Command failed with exit code = 1 
+0

是的。當解析命令時,配置單元解析器不支持引號,所以它試圖用3個參數執行'date',即'--date =「6」,然後是'月'然後'前'''。您沒有解決方法。空白空間不能逃脫。 –

回答

0

正如@samson在評論中提到的hive不解析命令--date="6 months ago";。您可以使用下面的解決方法。

select add_months(current_date(),-6);