【问题标题】:Hive query not working for more than 3 partitionsHive 查询不适用于超过 3 个分区
【发布时间】:2014-07-03 03:50:27
【问题描述】:

下面是我的蜂巢查询

'select substr(ltrim(date_ts),0,10) date_ts,
 sum(if(col1 = 'type1', 1, 0)) as type_1,
 sum(if(col1 = 'type2', 1, 0)) as type_2,
 sum(if(col1 = 'type3', 1, 0)) as type_3
 from table1
 GROUP BY substr(ltrim(date_ts),0,10) 
 ORDER BY date_ts;'

我的table1(外部表)被分区为(年字符串,月字符串,日字符串)

下面是我的分区

'year='2010',month='01',day='01'
 year='2010',month='01',day='02'
 year='2010',month='01',day='03'
 year='2010',month='01',day='04''

如果我在 3 个或更少的分区上运行查询,它就完全可以正常工作。当我添加第 4 个分区时,它会卡在 map=92% 处。无法弄清楚为什么。它正在处理任意 3 个分区的组合。不知道有没有人遇到过这个问题。

我能够得到以下输出。

' date        | type1  | type2     |type3 |
------------------------------------------
 2011-10-01   |    1   |  0        |  0   |
 2011-10-02   |    1   |  0        |  0   |
 2011-10-03   |    0   |  1        |  1   |'

在我为第四天添加第 4 个分区的那一刻,地图卡在 90% 左右,即使在 1 到 2 小时后仍然如此。

预期输出

' date        | type1  | type2     |type3 |
------------------------------------------
 2011-10-01   |    1   |  0        |  0   |
 2011-10-02   |    1   |  0        |  0   |
 2011-10-03   |    0   |  1        |  1   |
 2011-10-05   |    0   |  1        |  0   |'

有什么建议吗?

【问题讨论】:

    标签: hadoop hive hiveql


    【解决方案1】:

    四个分区是什么?看看你是否最终得到了

    __DEFAULT_PARTITION
    

    这意味着您在分区列中有一个空值。这会导致偏斜,从而导致..缓慢。

    如何做到这一点:

    use <your_database>;
    show partitions table table1;
    

    【讨论】:

    • 我用我的分区更新了这个问题。请看一看。如何检查我的分区列中是否有空值?
    • 您没有任何空分区值。我目前没有进一步的建议。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-17
    • 1970-01-01
    • 2017-04-25
    相关资源
    最近更新 更多