按时 间划分分区

问题描述 投票:0回答:1

我想实现

alter table dos_sourcedata add partition (data = to_date (current_timestamp ()));

在蜂巢中

每天在特定时间运行此语句。但这总是错误的。

hive partition hive-partitions
1个回答
0
投票

如果要使用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 ())

© www.soinside.com 2019 - 2024. All rights reserved.