GitHub user gatorsmile opened a pull request:

    https://github.com/apache/spark/pull/11846

    [SPARK-13957] [SQL] Support Group By Ordinal in SQL

    #### What changes were proposed in this pull request?
    This PR is to support group by position in SQL. For example, when users 
input the following query
    ```SQL
    select c1 as a, c2, c3, sum(*) from tbl group by 1, 3, c4
    ```
    The ordinals are recognized as the positions in the select list. Thus, 
`Analyzer` converts it to 
    ```SQL
    select c1, c2, c3, sum(*) from tbl group by c1, c3, c4
    ```
    
    This is controlled by the config option `spark.sql.groupByOrdinal`.
    - When true, the ordinal numbers in group by clauses are treated as the 
position in the select list.
    - When false, the ordinal numbers are ignored.
    - Only convert integer literals (not foldable expressions). If found 
foldable expressions, ignore them. 
    - When the positions specified in the group by clauses correspond to the 
aggregate functions in select list, output an exception message.
    
    Note: This PR is taken from https://github.com/apache/spark/pull/10731. 
When merging this PR, please give the credit to @zhichao-li
    
    Also cc all the people who are involved in the previous discussion:  @rxin 
@cloud-fan @marmbrus @yhuai @hvanhovell @adrian-wang @chenghao-intel 
@tejasapatil
    
    #### How was this patch tested?
    
    Added a few test cases for both positive and negative test cases.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/gatorsmile/spark groupByOrdinal

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/11846.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #11846
    
----
commit 95f25a6eb688a2cf3e3efa6ec7b7715884b1fa7b
Author: gatorsmile <gatorsm...@gmail.com>
Date:   2016-03-20T04:00:32Z

    group by ordinals

commit a9273761d4dfc3c7a95d570884bfbcc420a119e9
Author: gatorsmile <gatorsm...@gmail.com>
Date:   2016-03-20T04:08:37Z

    Merge remote-tracking branch 'upstream/master' into groupByOrdinal

commit b10d076a71d863255a901861f5ca571816d8fca7
Author: gatorsmile <gatorsm...@gmail.com>
Date:   2016-03-20T04:11:34Z

    fix messages.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to