【问题标题】:Range Partitioning in HiveHive 中的范围分区
【发布时间】:2014-10-20 13:08:26
【问题描述】:

hive 支持范围分区吗?

我的意思是 hive 是否支持以下内容:

insert overwrite table table2 PARTITION (employeeId BETWEEN 2001 and 3000) 
select employeeName FROM emp10 where employeeId BETWEEN 2001 and 3000;

其中 table2 & emp10 有两列:

员工姓名 & 员工编号

当我运行上述查询时,我遇到了一个错误:

FAILED: ParseException line 1:56 mismatched input 'BETWEEN' expecting ) near 'employeeId' in destination specification

【问题讨论】:

    标签: hadoop hive


    【解决方案1】:

    不可能。这是来自Hive documentation 的引用:

    一个表可以有一个或多个分区列,并且为分区列中的每个不同的值组合创建一个单独的数据目录

    【讨论】:

      【解决方案2】:

      不,这是不可能的。即使我使用单独的计算列,例如,

      insert overwrite table table2 PARTITION (employeeId_range) select employeeName , employeeId/1000 FROM emp10 where employeeId BETWEEN 2000 and 2999;

      这将确保所有值都落在同一个分区中。 在查询表格时,因为我们已经知道范围计算器,我们可以

      select employeeName , employeeId FROM table2 where employeeId_range=2;

      因此,我们还可以并行化给定范围的查询。 希望对您有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-05
        • 1970-01-01
        • 1970-01-01
        • 2020-06-05
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多