我试图在Hive中的另一个表中保存1个表(其数据每月重新计算)的数据(持有相同的数据但是一直都是这样)。但是,每当我尝试组合数据时,都会收到以下错误:
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;
令人沮丧的是,我将这些数据分区在另一列上,并且使用该分区重复此相同的过程没有问题。我试过谷歌搜索"动态分区不能是静态分区的父级"错误消息,但我无法找到导致此错误或如何修复的指导。我非常确定我的表格中有一个或多个设置的方式存在问题,但我无法看清楚。导致此错误的原因以及我可以解决的问题是什么?
答案 0 :(得分:0)
此脚本中没有partitioned by子句。当您尝试使用insert语句中的分区插入非分区表时,它会失败。
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';
答案 1 :(得分:0)
没有。您不需要添加分区子句。
您在group by mdcc.category
中正在insert overwrite table my_data_by_category partition(category)....
。但你没有使用任何UDAF。
你确定你能做到吗?
答案 2 :(得分:0)
我认为如果您将第二个创建语句更改为:
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';
你应该没有错误