在Hive视图顶部过滤是否会在视图中推送过滤器?

时间:2016-08-22 23:12:52

标签: hive

让MyTable上的MyView视图显示为: -

ff

现在假设我们触发以下查询: -

CREATE VIEW MyView AS SELECT col1,col2,...,colN from MyTable;

Hive是否在视图中推送过滤器(col =“abc”)以执行select?基本上试图了解Hive是否会在这里“推送优化”,如果我可以使用该术语。因为否则它将是非常低效的,因为View在整个表上并且在查询整个表之后,在视图之外将应用过滤器。

1 个答案:

答案 0 :(得分:0)

YES。

create view tmp.v_tmp0823 as select city_id, city_name from dw.dim_city ;

explain select city_id, city_name from tmp.v_tmp0823 where city_id = 123 ;

STAGE DEPENDENCIES:
  Stage-0 is a root stage

STAGE PLANS:
  Stage: Stage-0
    Fetch Operator
      limit: -1
      Processor Tree:
        TableScan
          alias: dim_city
          Statistics: Num rows: 530 Data size: 57323 Basic stats: COMPLETE Column stats: NONE
          Filter Operator
            predicate: (city_id = 123) (type: boolean)
             Statistics: Num rows: 265 Data size: 28661 Basic stats: COMPLETE Column stats: NONE
             Select Operator
               expressions: 123 (type: bigint), city_name (type: string)
               outputColumnNames: _col0, _col1
               Statistics: Num rows: 265 Data size: 28661 Basic stats: COMPLETE Column stats: NONE
               ListSink