You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by "Aman Sinha (JIRA)" <ji...@apache.org> on 2014/02/23 01:23:19 UTC

[jira] [Created] (DRILL-382) Doing Sort above an aggregate operator with group-by changes the ordinal position of columns

Aman Sinha created DRILL-382:
--------------------------------

             Summary: Doing Sort above an aggregate operator with group-by changes the ordinal position of columns
                 Key: DRILL-382
                 URL: https://issues.apache.org/jira/browse/DRILL-382
             Project: Apache Drill
          Issue Type: Bug
            Reporter: Aman Sinha


Doing a Sort above a grouping aggregate operator (either Streaming Aggr or Hash Aggr) produces output columns whose ordinal positions are non-deterministic.  See the output of the first and second runs below.  The physical plan to reproduce this is given further below.  Do we need a final Project to ensure the correct/consistent order of the columns ? 

First run:
----------------------------------
| Y              | $f0            |
-----------------------------------
| 50             | 0              |
| 47             | 1              |
| 68             | 2              |
| 77             | 3              |
| 58             | 4              |
-----------------------------------

Second run:
-----------------------------------
| $f0            | Y              |
-----------------------------------
| 0              | 50             |
| 1              | 47             |
| 2              | 68             |
| 3              | 77             |
| 4              | 58             |
-----------------------------------

Plan: 
{
  head : {
    version : 1,
    generator : {
      type : "optiq",
      info : "na"
    },
    type : "APACHE_DRILL_PHYSICAL"
  },
  graph : [ {
    pop : "parquet-scan",
    @id : 1,
    entries : [ {
      path : "/tmp/parquet/nation.parquet"
    } ],
    storageengine : {
      type : "parquet",
      dfsName : "file:///"
    },
    ref : "_MAP",
    fragmentPointer : 0
  }, {
    pop : "project",
    @id : 2,
    exprs : [ {
      ref : "output.$f0",
      expr : "_MAP.N_REGIONKEY"
    }, {
      ref : "output.$f1",
      expr : "_MAP.N_NATIONKEY"
    } ],
    child : 1
  }, {
    pop : "sort",
    @id : 3,
    child : 2,
    orderings : [ {
      order : "ASC",
      expr : "$f0"
    } ],
    reverse : false
  }, {
    pop : "streaming-aggregate",
    @id : 4,
    child : 3,
    keys : [ {
      ref : "$f0",
      expr : "$f0"
    } ],
    exprs : [ {
      ref : "Y",
      expr : "sum($f1) "
    } ]
  }, {
    pop : "sort",
    @id : 5,
    child : 4,
    orderings : [ {
      order : "ASC",
      expr : "$f0"
    }, {
      order : "ASC",
      expr : "Y"
    } ]
  }, {
    pop : "selection-vector-remover",
    @id : 6,
    child : 5
  }, {
    pop : "screen",
    @id : 7,
    child : 6
  } ]
}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)