【问题标题】:using hive to select data within large range partitions使用 hive 在大范围分区中选择数据
【发布时间】:2014-02-21 07:48:41
【问题描述】:

我在使用 hive 在大范围分区中选择数据时遇到了一些问题

这是我要执行的 HQL:

INSERT OVERWRITE TABLE summary_T partition(DateRange='20131222-20131228')
select col1, col2, col3 From RAW_TABLE 
where cdate between '20131222' and '20131228' 
and (trim(col1) IS NULL or trim(col1)='')
and length(col2)=12;

“cdate”是表RAW_TABLE的分区

但在给我工作 ID 后它卡住了

一旦我把它改成:

INSERT OVERWRITE TABLE summary_T partition(DateRange='20131222-20131228')
select col1, col2, col3 From RAW_TABLE 
where cdate between '20131222' and '20131225' 
and (trim(col1) IS NULL or trim(col1)='')
and length(col2)=12;

然后它开始工作

是否有任何解决方案可以帮助我执行第一个 HQL?

感谢您的帮助!

【问题讨论】:

    标签: hadoop hql hive hadoop-partitioning


    【解决方案1】:

    我遇到了类似的问题,并尝试在我的 SELECT 语句末尾使用CLUSTER BY 'partition_column'。使用它后,我可以在更大的日期范围内执行我的 INSERT。

    因此,如果您将查询更改为:

    INSERT OVERWRITE TABLE summary_T partition(DateRange='20131222-20131228')
    select col1, col2, col3 From RAW_TABLE 
    where cdate between '20131222' and '20131228' 
    and (trim(col1) IS NULL or trim(col1)='')
    and length(col2)=12
    CLUSTER BY DateRange;
    

    性能会提高。

    有关 CLUSTER BY 如何帮助查询的说明,您可以浏览此手册页,其中详细说明了它:

    https://cwiki.apache.org/confluence/display/Hive/LanguageManual+SortBy

    【讨论】:

    • 感谢分享您的经验!!我会试试这个方法然后报告回来。
    • 我在上面得到一个错误:FAILED: SemanticException [Error 10004]: Line 6:11 Invalid table alias or column reference 'DateRange': (可能的列名是:col1, col2, col3) 看起来像它无法使用分区列执行“CLUSTER BY”
    • 请先尝试使用 CLUSTER BY 执行 Select 语句。就我而言,我能够执行 INSERT。它没有抛出任何此类错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-02
    • 2019-06-18
    • 2019-09-30
    • 2020-10-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多