Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-582

"SELECT count(1) as cnt from src x" not working for column pruning

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.4.0
    • None
    • None
    • Reviewed

    Description

      The query "SELECT count(1) as cnt from src x" has some problems, even though nullgroup*.q passed in tests.
      Will check and solve it in this jira.
      A wrong plan sometimes can be generated due to some unknow factor:
      Wrong plan:

      STAGE PLANS:
        Stage: Stage-1
          Map Reduce
            Alias -> Map Operator Tree:
              x 
                  Select Operator
                    Reduce Output Operator
                      sort order: 
                      tag: -1
            Reduce Operator Tree:
              Group By Operator
                aggregations:
                      expr: count(VALUE._col0)
                mode: complete
                Select Operator
                  expressions:
                        expr: _col0
                        type: bigint
                  File Output Operator
                    compressed: false
                    GlobalTableId: 0
                    table:
                        input format: org.apache.hadoop.mapred.TextInputFormat
                        output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
      
        Stage: Stage-0
          Fetch Operator
            limit: -1
      

      Without unknow factor, correct plan can be generated:

      STAGE PLANS:
        Stage: Stage-1
          Map Reduce
            Alias -> Map Operator Tree:
              x 
                  Select Operator
                    Group By Operator
                      aggregations:
                            expr: count(1)
                      mode: hash
                      Reduce Output Operator
                        sort order: 
                        tag: -1
                        value expressions:
                              expr: _col0
                              type: bigint
            Reduce Operator Tree:
              Group By Operator
                aggregations:
                      expr: count(VALUE._col0)
                mode: mergepartial
                Select Operator
                  expressions:
                        expr: _col0
                        type: bigint
                  File Output Operator
                    compressed: false
                    GlobalTableId: 0
                    table:
                        input format: org.apache.hadoop.mapred.TextInputFormat
                        output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
      

      Attachments

        1. hive-582-2009-06-25.patch
          10 kB
          He Yongqiang

        Activity

          People

            he yongqiang He Yongqiang
            he yongqiang He Yongqiang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: