【问题标题】:SemanticException Partition spec {col=null} contains non-partition columnsSemanticException 分区规范 {col=null} 包含非分区列
【发布时间】:2018-03-21 08:52:40
【问题描述】:

我正在尝试使用以下代码在 hive 中创建动态分区。

SET hive.exec.dynamic.partition = true;
SET hive.exec.dynamic.partition.mode = nonstrict;

create external table if not exists report_ipsummary_hourwise(
ip_address string,imp_date string,imp_hour bigint,geo_country string)
PARTITIONED BY (imp_date_P string,imp_hour_P string,geo_coutry_P string) 
row format delimited 
fields terminated by '\t'
stored as textfile
location 's3://abc';

insert overwrite table report_ipsummary_hourwise PARTITION (imp_date_P,imp_hour_P,geo_country_P)
SELECT ip_address,imp_date,imp_hour,geo_country,
       imp_date as imp_date_P,
       imp_hour as imp_hour_P,
       geo_country as geo_country_P
FROM report_ipsummary_hourwise_Temp;

其中 report_ipsummary_hourwise_Temp 表包含以下列, ip_address,imp_date,imp_hour,geo_country。

我收到了这个错误

SemanticException 分区规范 {imp_hour_p=null, imp_date_p=null, geo_country_p=null} 包含非分区列。

谁能指出为什么会出现这个错误?

【问题讨论】:

  • 2年前你能解决吗?

标签: dynamic hive partitioning


【解决方案1】:

您插入的 sql 具有 geo_country_P 列,但目标表列名称为 geo_coutry_P。错过国家

n

【讨论】:

  • 这个错误是另外一回事。即使在此名称更正之后也会出现同样的错误
  • 我遇到了类似的问题,问题是我的INSERTPARTITION 子句中有错字。 PARTITION 子句中列出的列必须与表 create 中定义的名称匹配。
  • 我本来打算投反对票,但后来我傲慢的内心告诉我只做一次拼写检查,我发现了错误:) ..
【解决方案2】:

我遇到了同样的错误。这是因为文件中存在额外的字符。 最好的解决方案是删除所有空白字符并根据需要重新插入。

【讨论】:

    【解决方案3】:

    也可以是https://issues.apache.org/jira/browse/HIVE-14032

    INSERT OVERWRITE 命令失败,分区键名区分大小写

    Hive 中有一个错误使分区列名区分大小写。

    对我来说,解决方法是表中的两个列名都必须小写 并且表定义中的 PARTITION BY 子句必须是小写的。 (它们也可以都是大写;由于这个 Hive 错误 HIVE-14032,大小写必须匹配)

    【讨论】:

      【解决方案4】:

      它说在将文件从结果复制到 hdfs 作业时无法识别分区位置。我可以怀疑你有分区表(imp_date_P,imp_hour_P,geo_country_P),而工作正试图在 imp_hour_p=null,imp_date_p=null,geo_country_p=null 上复制不匹配..尝试检查 hdfs 位置...另一点我可以建议不要重复列名和分区两次

      【讨论】:

        猜你喜欢
        • 2021-01-21
        • 1970-01-01
        • 2018-01-03
        • 2014-12-05
        • 1970-01-01
        • 2021-09-22
        • 2021-10-13
        • 2015-02-11
        • 2011-10-22
        相关资源
        最近更新 更多