【问题标题】:Hive - insert into table partition throwing errorHive - 插入表分区抛出错误
【发布时间】:2018-09-07 23:23:14
【问题描述】:

我正在尝试在 Hive on spark 中创建一个分区表,并使用 Hive 中其他表中可用的数据加载它。 加载数据时出现以下错误:

错误:org.apache.spark.sql.AnalysisException: org.apache.hadoop.hive.ql.metadata.Table.ValidationFailureSemanticException: 分区规格 {cardsuit=, cardcolor=, cardSuit=SPA, cardColor=BLA} 包含非分区列;

以下是用于执行任务的命令:-

create table if not exists hive_tutorial.hive_table(color string, suit string,value string) comment 'first hive table' row format delimited fields terminated by '|' stored as TEXTFILE;

LOAD DATA LOCAL INPATH 'file:///E:/Kapil/software-study/Big_Data_NoSql/hive/deckofcards.txt' OVERWRITE INTO TABLE hive_table; --data is correctly populated(52 rows)

SET hive.exec.dynamic.partition = true;

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

create table if not exists hive_tutorial.hive_table_partitioned(color string, suit string,value int) comment 'first hive table' partitioned by (cardSuit string,cardColor string) row format delimited fields terminated by '|' stored as TEXTFILE;

INSERT INTO TABLE hive_table_partitioned PARTITION (cardSuit,cardColor) select color,suit,value,substr(suit, 1, 3) as cardSuit,substr(color, 1, 3) as cardColor from hive_table;

--alternatively i tried
INSERT OVERWRITE  TABLE hive_table_partitioned PARTITION (cardSuit,cardColor) select color,suit,value,substr(suit, 1, 3) as cardSuit,substr(color, 1, 3) as cardColor from hive_table;

数据样本:-

黑色|黑桃|2

黑|黑桃|3

黑色|黑桃|4

黑|黑桃|5

黑|黑桃|6

黑|黑桃|7

黑色|黑桃|8

黑色|黑桃|9

我使用的是 spark 2.2.0 和 java 版本 1.8.0_31。

我已经检查并尝试了类似线程中给出的答案,但无法解决我的问题:- SemanticException Partition spec {col=null} contains non-partition columns

我错过了什么吗?

【问题讨论】:

    标签: apache-spark hive hiveql spark-thriftserver


    【解决方案1】:

    在创建表时仔细阅读上面的脚本后,value 列在分区表中是 int 类型,而原始类型是 string。错误是误导!!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-03
      • 2023-04-02
      • 2015-09-13
      • 1970-01-01
      • 2019-04-29
      • 2020-01-13
      • 2019-02-16
      • 2020-02-10
      相关资源
      最近更新 更多