我尝试将一个表(其数据每月重新计算)中的数据聚合到Hive中的另一个表(保存相同的数据,但始终保持相同的数据)中。但是,每当我尝试组合数据时,我都会得到以下错误:
FAILED: SemanticException [Error 10094]: Line 3:74 Dynamic partition cannot be the parent of a static partition 'category'我用来创建表的代码如下:
create table my_data_by_category (views int, submissions int)
partitioned by (category string)
row format delimited
fields terminated by ','
escaped by '\\'
location '${hiveconf:OUTPUT}/${hiveconf:DATE_DIR}/my_data_by_category';
create table if not exists my_data_lifetime_total_by_category
like my_data_by_category
row format delimited
fields terminated by ','
escaped by '\\'
stored as textfile
location '${hiveconf:OUTPUT}/lifetime-totals/my_data_by_category';我用来填充表的代码如下:
insert overwrite table my_data_by_category partition(category)
select mdcc.col1, mdcc2.col2, pcc.category
from my_data_col1_counts_by_category mdcc
left outer join my_data_col2_counts_by_category mdcc2 where mdcc.category = mdcc2.category
group by mdcc.category, mdcc.col1, mdcc2.col2;
insert overwrite table my_data_lifetime_total_by_category partition(category)
select mdltc.col1 + mdc.col1 as col1, mdltc.col2 + mdc.col2, mdc.category
from my_data_lifetime_total_by_category mdltc
full outer join my_data_by_category mdc on mdltc.category = mdc.category
where mdltc.col1 is not null and mdltc.col2 is not null;令人沮丧的是,我将此数据分区到另一个列上,并对该分区重复相同的过程,没有任何问题。我试着用谷歌搜索“动态分区不能成为静态分区的父分区”的错误信息,但我找不到任何关于这是什么原因或如何修复的指导。我非常确定,我的一个或多个表的设置方式存在问题,但我看不到是什么。是什么导致了这个错误?我能做些什么来解决它?
发布于 2015-12-04 08:16:36
此脚本中没有partitioned子句。当您尝试在insert语句中使用partition插入到非分区表中时,该操作失败。
create table if not exists my_data_lifetime_total_by_category
like my_data_by_category
row format delimited
fields terminated by ','
escaped by '\\'
stored as textfile
location '${hiveconf:OUTPUT}/lifetime-totals/my_data_by_category';发布于 2015-12-04 14:24:32
不是的。不需要添加partition子句。
您正在insert overwrite table my_data_by_category partition(category)....中执行group by mdcc.category。但是您没有使用任何UDAF。你确定你能做到吗?
发布于 2016-03-18 06:06:53
我认为如果您将第二个create语句更改为:
create table if not exists my_data_lifetime_total_by_category
partitioned by (category string)
row format delimited
fields terminated by ','
escaped by '\\'
stored as textfile
location '${hiveconf:OUTPUT}/lifetime-totals/my_data_by_category';这样就不会出现错误。
https://stackoverflow.com/questions/34076529
复制相似问题