【问题标题】:Dynamic partitioning动态分区
【发布时间】:2021-05-17 16:40:55
【问题描述】:

我在 hive 中创建了一个外部表,使用:

create external table if not exists summary(
    `Restaurant ID` INT,
    `Restaurant Name` STRING)
PARTITIONED BY (p_filedate INT, p_country_name STRING)
stored as ORC;

现在,当我尝试使用以下方法填充表格时:

INSERT overwrite table zomato_summary partition(p_filedate,p_country_name)
SELECT  
        `restaurant id`,
         ISNULL( `restaurant name`,'NA')
FROM Sales;

我收到以下错误:

FAILED: SemanticException [Error 10011]: Invalid function any

可能 Hive 将 partition 关键字视为 UDF,这就是它导致错误的原因。

请建议对多列进行动态分区的替代方法。

【问题讨论】:

    标签: sql hive bigdata partitioning data-partitioning


    【解决方案1】:

    在动态模式下加载分区时,select 应该包括分区列(与表 DDL 中的顺序相同)。

    例如这样:

    SET hive.exec.dynamic.partition=true;
    SET hive.exec.dynamic.partition.mode=nonstrict;
    
    INSERT overwrite table zomato_summary partition(p_filedate,p_country_name)
    SELECT  
            `restaurant id`,
             ISNULL( `restaurant name`,'NA'), --ISNULL exists not in all versions, use COALESCE or NVL
             current_date, --or proper column from sales 
             country_name
    FROM Sales;
    

    【讨论】:

      猜你喜欢
      • 2018-06-06
      • 1970-01-01
      • 2022-01-22
      • 2016-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-17
      • 1970-01-01
      相关资源
      最近更新 更多