我想实现
alter table dos_sourcedata add partition (data = to_date (current_timestamp ()));
在蜂巢中
每天在特定时间运行此语句。但这总是错误的。
如果要使用alter table创建空分区,请使用值而不是表达式,例如:
alter table mytable add partition (partition_date='2020-04-01');
您可以使用插入覆盖表分区在加载数据时动态创建分区,在这种情况下,您可以在查询中使用表达式:
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table mytable partition (partition_date)
select
col_1,
...
col_n,
current_date --partition column is the last one
from ...
使用current_date
代替to_date (current_timestamp ())
。