hadoop - Hive 查询执行计划

标签 hadoop hive mapreduce hiveql

这是我的配置单元查询

Insert into schemaB.employee partition(year) 
select * from schemaA.employee;

下面是这个查询产生的查询执行计划。

hive> explain <query>;

STAGE DEPENDENCIES:
  Stage-1 is a root stage
  Stage-0 depends on stages: Stage-1
  Stage-2 depends on stages: Stage-0

STAGE PLANS:
  Stage: Stage-1
    Map Reduce
      Map Operator Tree:
          TableScan
            alias: employee
            Statistics: Num rows: 65412411 Data size: 59121649936 Basic stats: COMPLETE Column stats: NONE
            Select Operator
              expressions: Col1 (type: binary), col2 (type: binary), col3 (type: array<string>), year (type: int)
              outputColumnNames: _col0, _col1, _col2, _col3
              Statistics: Num rows: 65412411 Data size: 59121649936 Basic stats: COMPLETE Column stats: NONE
              Reduce Output Operator
                key expressions: _col3 (type: int)
                sort order: +
                Map-reduce partition columns: _col3 (type: int)
                Statistics: Num rows: 65412411 Data size: 59121649936 Basic stats: COMPLETE Column stats: NONE
                value expressions: _col0 (type: binary), _col1 (type: binary), _col2 (type: array<string>), _col3 (type: int)
      Reduce Operator Tree:
        Extract
          Statistics: Num rows: 65412411 Data size: 59121649936 Basic stats: COMPLETE Column stats: NONE
          File Output Operator
            compressed: true
            Statistics: Num rows: 65412411 Data size: 59121649936 Basic stats: COMPLETE Column stats: NONE
            table:
                input format: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat
                output format: org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat
                serde: org.apache.hadoop.hive.ql.io.orc.OrcSerde
                name: schemaB.employee

  Stage: Stage-0
    Move Operator
      tables:
          partition:
            year 
          replace: false
          table:
              input format: org.apache.hadoop.hive.ql.io.orc.OrcInputFormat
              output format: org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat
              serde: org.apache.hadoop.hive.ql.io.orc.OrcSerde
              name: schemaB.employee

  Stage: Stage-2
    Stats-Aggr Operator

我有两个与查询执行计划相关的问题:

  1. 为什么查询计划中有一个reduce步骤?在我的理解中,它需要做的就是将数据从一个HDFS位置复制到另一个位置,这可以单独通过映射器来实现。 reduce 步骤是否与表中存在的分区有关?
  2. 阶段 2 中的Stats-Aggr Operator 步骤是什么?我找不到对此进行解释的相关文档。

最佳答案

这回答了这两个问题。
默认情况下会自动收集统计信息,为此需要减少步骤。

https://cwiki.apache.org/confluence/display/Hive/Configuration+Properties#ConfigurationProperties-Statistics

hive.stats.autogather

Default Value: true 

Added In: Hive 0.7 with HIVE-1361

A flag to gather statistics automatically during the INSERT OVERWRITE command.

关于hadoop - Hive 查询执行计划,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43448218/

相关文章:

hadoop - Apache HIVE 中的表定义问题

hadoop - 压缩MapReduce的输出文件,而不合并它们

mapreduce - 映射/减少以获取按键分组的每个文档的计数和最新日期

hadoop - 将 Pig 与 Hbase 集成

Hadoop 无法完成作业,因为 "No space left on device"

java - Maven:当前项目和依赖项目使用同一个库的不同版本

hadoop - Apache Solr 支持 ORC 文件格式

java - 尝试使用 SqoopOptions 将数据从 Mysql 导入到 hive

hadoop - Hive外部表-删除分区

hadoop - 有什么工具可以让我从两个表中加入数据——一个在 hive 中,另一个在 cassandra 中。我也必须通过 oozie 来完成这项工作