在以下hiveql代码中,我想向现有表添加分区:
-- my_table was defined and partitioned by `dt string`, which is date
-- now I want to add partition
alter table my_table add if not exists
partition (dt=current_date()); #FAILED: ParseException line 1:72 extraneous input '(' expecting ) near '<EOF>'
alter table my_table add if not exists
partition (dt=${current_date()}); # FAILED: ParseException line 1:60 cannot recognize input near '$' '{' 'current_date' in constant
但是,上面的代码不起作用,为什么?还有别的办法吗?
1条答案
按热度按时间qoefvg9y1#
配置单元需要alter分区中的文本
另外,当前的\u日期只能从Hive2.0中获得,因此基于您的错误,您可能正在使用较低的版本。
解决方法。
用以下语句编写一个文件
并调用hive-like(在linux中)
我希望这对你有帮助。
ps:我想在Hive2.0中尝试使用alter命令和current\u date,无论如何,您应该像current\u date一样使用它,而不是current\u date()