首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >动态分区不能是静态分区的父分区

动态分区不能是静态分区的父分区
EN

Stack Overflow用户
提问于 2015-12-04 05:30:36
回答 3查看 5.3K关注 0票数 2

我尝试将一个表(其数据每月重新计算)中的数据聚合到Hive中的另一个表(保存相同的数据,但始终保持相同的数据)中。但是,每当我尝试组合数据时,我都会得到以下错误:

代码语言:javascript
复制
FAILED: SemanticException [Error 10094]: Line 3:74 Dynamic partition cannot be the parent of a static partition 'category'

我用来创建表的代码如下:

代码语言:javascript
复制
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';

我用来填充表的代码如下:

代码语言:javascript
复制
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;

令人沮丧的是,我将此数据分区到另一个列上,并对该分区重复相同的过程,没有任何问题。我试着用谷歌搜索“动态分区不能成为静态分区的父分区”的错误信息,但我找不到任何关于这是什么原因或如何修复的指导。我非常确定,我的一个或多个表的设置方式存在问题,但我看不到是什么。是什么导致了这个错误?我能做些什么来解决它?

EN

回答 3

Stack Overflow用户

发布于 2015-12-04 08:16:36

此脚本中没有partitioned子句。当您尝试在insert语句中使用partition插入到非分区表中时,该操作失败。

代码语言:javascript
复制
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';
票数 0
EN

Stack Overflow用户

发布于 2015-12-04 14:24:32

不是的。不需要添加partition子句。

您正在insert overwrite table my_data_by_category partition(category)....中执行group by mdcc.category。但是您没有使用任何UDAF。你确定你能做到吗?

票数 0
EN

Stack Overflow用户

发布于 2016-03-18 06:06:53

我认为如果您将第二个create语句更改为:

代码语言:javascript
复制
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';

这样就不会出现错误。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34076529

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档