Hive 分区表 - 尝试将数据从一个表加载到我的 Hive 中的分区表并得到 [错误 10044]*
Posted
技术标签:
【中文标题】Hive 分区表 - 尝试将数据从一个表加载到我的 Hive 中的分区表并得到 [错误 10044]*【英文标题】:Hive Partitioned Table - trying to load data from one table to a partitioned table in my Hive and getting [Error 10044]* 【发布时间】:2020-07-10 02:01:20 【问题描述】:所以我有一个包含 20 列的表,并且我创建了另一个分区表 - 使用 2 个分区值,现在当我尝试将具有 20 列的表中的数据加载到其他分区表中时,我收到错误消息说我的分区表有更多列而不是我从中插入数据的表
我的创建表语句:
create table flight_data_parquet(
YEAR INT,
FL_DATE STRING,
UNIQUE_CARRIER STRING,
AIRLINE_ID INT,
CARRIER STRING,
TAIL_NUM STRING,
FL_NUM INT,
ORIGIN_AIRPORT_ID INT,
ORIGIN_AIRPORT_SEQ_ID INT,
ORIGIN STRING,
DEST_AIRPORT_ID INT,
DEST_AIRPORT_SEQ_ID INT,
DEST STRING,
DEP_DELAY FLOAT,
ARR_DELAY FLOAT,
CANCELLED TINYINT,
DIVERTED TINYINT,
DISTANCE INT)
partitioned by (Month INT, DAY_OF_MONTH INT)stored AS PARQUET;
-插入声明:
insert into table flight_data_parquet partition(month=1, day_of_month)
select YEAR,FL_DATE,
UNIQUE_CARRIER,
AIRLINE_ID,
CARRIER,
TAIL_NUM,
FL_NUM,
ORIGIN_AIRPORT_ID,
ORIGIN_AIRPORT_SEQ_ID,
ORIGIN,
DEST_AIRPORT_ID,
DEST_AIRPORT_SEQ_ID,
DEST,
DEP_DELAY,
ARR_DELAY,
CANCELLED,
DIVERTED,
DISTANCE, month, day_of_month
from flight_data_v2 where month=1;
我得到的错误是 -
FAILED: SemanticException [Error 10044]: Line 1:18 Cannot insert into target table because column number/types are different 'day_of_month': Table insclause-0 has 19 columns, but query has 20 columns.
hive (flights)>
【问题讨论】:
【参考方案1】:month=1
in the partition specification partition(month=1, day_of_month) - 是一个静态分区并且值已经指定,从选择查询中删除month
。只有day_of_month
(动态分区)应该在选择中:
insert into table flight_data_parquet partition(month=1, day_of_month) -- Month=1 is a static partition
select YEAR,FL_DATE,
UNIQUE_CARRIER,
AIRLINE_ID,
CARRIER,
TAIL_NUM,
FL_NUM,
ORIGIN_AIRPORT_ID,
ORIGIN_AIRPORT_SEQ_ID,
ORIGIN,
DEST_AIRPORT_ID,
DEST_AIRPORT_SEQ_ID,
DEST,
DEP_DELAY,
ARR_DELAY,
CANCELLED,
DIVERTED,
DISTANCE, day_of_month
from flight_data_v2 where month=1;
【讨论】:
以上是关于Hive 分区表 - 尝试将数据从一个表加载到我的 Hive 中的分区表并得到 [错误 10044]*的主要内容,如果未能解决你的问题,请参考以下文章