配置单元查询计划-了解阶段的输入和输出。

时间:2018-09-28 17:58:04

标签: hadoop hive hiveql

我正在尝试了解简单的distinct查询的配置单元查询计划,并且其中一个阶段的输出混乱程度很小。

我有一个只有两列的简单表,即id和value。只需4行,如下所述。

数据:

hive> select * from temp.test_distinct;
OK
1   100
2   100
3   100
4   150 

计划

hive> explain select distinct value from temp.test_distinct;
OK
Plan not optimized by CBO.

Vertex dependency in root stage
Reducer 2 <- Map 1 (SIMPLE_EDGE)

Stage-0
   Fetch Operator
      limit:-1
      Stage-1
         Reducer 2
         File Output Operator [FS_6]
            compressed:false
            Statistics:Num rows: 2 Data size: 10 Basic stats: COMPLETE Column stats: NONE
            table:{"input format:":"org.apache.hadoop.mapred.TextInputFormat","output format:":"org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat","serde:":"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe"}
            Group By Operator [GBY_4]
            |  keys:KEY._col0 (type: string)
            |  outputColumnNames:["_col0"]
            |  Statistics:Num rows: 2 Data size: 10 Basic stats: COMPLETE Column stats: NONE
            |<-Map 1 [SIMPLE_EDGE]
               Reduce Output Operator [RS_3]
                  key expressions:_col0 (type: string)
                  Map-reduce partition columns:_col0 (type: string)
                  sort order:+
                  Statistics:Num rows: 4 Data size: 20 Basic stats: COMPLETE Column stats: NONE
                  Group By Operator [GBY_2]
                     keys:value (type: string)
                     outputColumnNames:["_col0"]
                     Statistics:Num rows: 4 Data size: 20 Basic stats: COMPLETE Column stats: NONE
                     Select Operator [SEL_1]
                        outputColumnNames:["value"]
                        Statistics:Num rows: 4 Data size: 20 Basic stats: COMPLETE Column stats: NONE
                        TableScan [TS_0]
                           alias:test_distinct
                           Statistics:Num rows: 4 Data size: 20 Basic stats: COMPLETE Column stats: NONE

Time taken: 0.181 seconds, Fetched: 35 row(s)

困惑:

TableScan,“选择运算符”和“按运算符分组”显示他们处理了 4行,这对我来说很有意义。但是在按操作员分组之后的下一阶段不应该仅获得 2行。作为分组依据将删除其他行。

在我的 DAG 中,我可以看到mapper的输出仅是两行,而不是四行,但是与Plan不匹配。

我可以看错吗?

0 个答案:

没有答案