【问题标题】:hive partition by time蜂巢按时间分区
【发布时间】:2020-03-29 08:41:11
【问题描述】:

我要实现

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

在蜂巢中

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

【问题讨论】:

标签: hive partition hive-partitions hiveddl


【解决方案1】:

如果您想使用alter table 创建空分区,请使用值,而不是表达式,如下所示:

alter table mytable add partition (partition_date='2020-04-01');

可以在加载数据时使用insert overwrite table partition动态创建分区,此时可以在查询中使用表达式:

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 ())

【讨论】:

    猜你喜欢
    • 2015-05-20
    • 1970-01-01
    • 1970-01-01
    • 2020-08-26
    • 2014-11-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-17
    • 1970-01-01
    相关资源
    最近更新 更多