姜小嫌

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

hive 语句执行顺序

from... where.... select...group by... having ... order by...

执行计划

Map Operator Tree:
TableScan
            alias: 表名   -- 相当于 from ...

Filter Operator
              predicate: where中的字段  -- 过滤where字段的条件

Select Operator
                expressions: select 中的字段 + 类型type    -- select
                outputColumnNames: 输出的字段  -- select
Group By Operator
                  aggregations: 聚合函数 sum(age)/count(age)等 
                  keys: group by 中的字段 + 类型type 
Reduce Output Operator
                 map端本地的reduce

Reduce Operator Tree:
Group By Operator
          aggregations: sum(VALUE._col0)   --reduce 聚合函数 对虚拟列
          keys: KEY._col0 (type: string), KEY._col1 (type: string), KEY._col2 (type: string) 
          mode: mergepartial
              outputColumnNames: _col0, _col1, _col2, _col3 --为临时结果字段按规则起的临时字段名
Select Operator
            expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: bigint) --select
            outputColumnNames: _col0, _col1, _col2, _col3 -- 输出虚拟列(为临时结果字段按规则起的临时字段名)
            
File Output Operator
              compressed: false
              

未完待续

posted on 2017-07-12 15:15  姜小嫌  阅读(6492)  评论(1编辑  收藏  举报