1. 使用EXPLAIN
通过EXPLAIN功能,可以帮助我们了解如何将查询转化成MapReduce任务的。
1、使用explain查看hive如何将查询转化成MapReduce任务的 1.1 创建表 create table onecol(number int) 1.2 初始化数据并加载 [hadoop@mycluster ~]$ vi onecol 1 2 3 4 5
hive (default)> load data local inpath '/home/hadoop/onecol' overwrite into table onecol;
1.3 通过explain查看 hive (default)> explain select sum(number) from onecol; OK Explain STAGE DEPENDENCIES: Stage-1 is a root stage Stage-0 is a root stage
STAGE PLANS: Stage: Stage-1 Map Reduce Map Operator Tree: TableScan alias: onecol Statistics: Num rows: 2 Data size: 10 Basic stats: COMPLETE Column stats: NONE Select Operator expressions: number (type: int) outputColumnNames: number Statistics: Num rows: 2 Data size: 10 Basic stats: COMPLETE Column stats: NONE Group By Operator aggregations: sum(number) mode: hash outputColumnNames: _col0 Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE Reduce Output Operator sort order: Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE value expressions: _col0 (type: bigint) Reduce Operator Tree: Group By Operator aggregations: sum(VALUE._col0) mode: mergepartial outputColumnNames: _col0 Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE Select Operator expressions: _col0 (type: bigint) outputColumnNames: _col0 Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE File Output Operator compressed: false Statistics: Num rows: 1 Data size: 8 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
Stage: Stage-0 Fetch Operator limit: -1
|