1

我正在尝试在 Spark 上的 Hive 中创建一个分区表,并使用 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

我在这里错过了什么吗?

4

1 回答 1

0

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

于 2018-04-23T05:26:02.087 回答