Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-3210

Star is not expanded correctly in projection list when used with window function

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      Just star ...

      0: jdbc:drill:schema=dfs> select * , sum(a1) over (partition by b1) from t1;
      +-----------+-----------+-------------+-------+--------+--------+--------+---------+----------+
      | T124¦¦a1  | T124¦¦b1  |  T124¦¦c1   |  a1   |   b1   | w0$o0  | w0$o1  | EXPR$1  | EXPR$10  |
      +-----------+-----------+-------------+-------+--------+--------+--------+---------+----------+
      | 1         | aaaaa     | 2015-01-01  | 1     | aaaaa  | 1      | 1      | 1       | 1        |
      | 2         | bbbbb     | 2015-01-02  | 2     | bbbbb  | 1      | 2      | 2       | 2        |
      | 3         | ccccc     | 2015-01-03  | 3     | ccccc  | 1      | 3      | 3       | 3        |
      | 5         | eeeee     | 2015-01-05  | 5     | eeeee  | 1      | 5      | 5       | 5        |
      | 6         | fffff     | 2015-01-06  | 6     | fffff  | 1      | 6      | 6       | 6        |
      | 7         | ggggg     | 2015-01-07  | 7     | ggggg  | 1      | 7      | 7       | 7        |
      | null      | hhhhh     | 2015-01-08  | null  | hhhhh  | 0      | 0      | null    | null     |
      | 9         | iiiii     | null        | 9     | iiiii  | 1      | 9      | 9       | 9        |
      | 10        | jjjjj     | 2015-01-10  | 10    | jjjjj  | 1      | 10     | 10      | 10       |
      | 4         | null      | 2015-01-04  | 4     | null   | 1      | 4      | 4       | 4        |
      +-----------+-----------+-------------+-------+--------+--------+--------+---------+----------+
      10 rows selected (0.163 seconds)
      

      t1 with the star ...

      0: jdbc:drill:schema=dfs> select t1.* , sum(a1) over (partition by b1) from t1;
      +-----------+-----------+-------------+-------+--------+--------+--------+---------+----------+
      | T125¦¦a1  | T125¦¦b1  |  T125¦¦c1   |  a1   |   b1   | w0$o0  | w0$o1  | EXPR$1  | EXPR$10  |
      +-----------+-----------+-------------+-------+--------+--------+--------+---------+----------+
      | 1         | aaaaa     | 2015-01-01  | 1     | aaaaa  | 1      | 1      | 1       | 1        |
      | 2         | bbbbb     | 2015-01-02  | 2     | bbbbb  | 1      | 2      | 2       | 2        |
      | 3         | ccccc     | 2015-01-03  | 3     | ccccc  | 1      | 3      | 3       | 3        |
      | 5         | eeeee     | 2015-01-05  | 5     | eeeee  | 1      | 5      | 5       | 5        |
      | 6         | fffff     | 2015-01-06  | 6     | fffff  | 1      | 6      | 6       | 6        |
      | 7         | ggggg     | 2015-01-07  | 7     | ggggg  | 1      | 7      | 7       | 7        |
      | null      | hhhhh     | 2015-01-08  | null  | hhhhh  | 0      | 0      | null    | null     |
      | 9         | iiiii     | null        | 9     | iiiii  | 1      | 9      | 9       | 9        |
      | 10        | jjjjj     | 2015-01-10  | 10    | jjjjj  | 1      | 10     | 10      | 10       |
      | 4         | null      | 2015-01-04  | 4     | null   | 1      | 4      | 4       | 4        |
      +-----------+-----------+-------------+-------+--------+--------+--------+---------+----------+
      10 rows selected (0.158 seconds)
      

      Explain plan:

      0: jdbc:drill:schema=dfs> explain plan for select * , sum(a1) over (partition by b1) from t1;
      +------+------+
      | text | json |
      +------+------+
      | 00-00    Screen
      00-01      ProjectAllowDup(*=[$0], EXPR$1=[$1])
      00-02        Project(*=[$0], EXPR$1=[CASE(>($3, 0), CAST($4):ANY, null)])
      00-03          Window(window#0=[window(partition {2} order by [] range between UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING aggs [COUNT($1), $SUM0($1)])])
      00-04            SelectionVectorRemover
      00-05              Sort(sort0=[$2], dir0=[ASC])
      00-06                Project(T126¦¦*=[$0], a1=[$1], b1=[$2])
      00-07                  Scan(groupscan=[ParquetGroupScan [entries=[ReadEntryWithPath [path=maprfs:///drill/testdata/subqueries/t1]], selectionRoot=/drill/testdata/subqueries/t1, numFiles=1, columns=[`*`]]])
      

      Table schema:

      0: jdbc:drill:schema=dfs> select * from t1 limit 1;
      +-----+--------+-------------+
      | a1  |   b1   |     c1      |
      +-----+--------+-------------+
      | 1   | aaaaa  | 2015-01-01  |
      +-----+--------+-------------+
      1 row selected (0.119 seconds)
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jni Jinfeng Ni
            vicky Victoria Markman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment