diff options
author | gatorsmile <gatorsmile@gmail.com> | 2016-03-25 12:55:58 +0800 |
---|---|---|
committer | Wenchen Fan <wenchen@databricks.com> | 2016-03-25 12:55:58 +0800 |
commit | 05f652d6c2bbd764a1dd5a45301811e14519486f (patch) | |
tree | 46640388ac61767de19808901ba0b59de456bb92 /R/pkg/inst/tests/testthat/test_take.R | |
parent | 0874ff3aade705a97f174b642c5db01711d214b3 (diff) | |
download | spark-05f652d6c2bbd764a1dd5a45301811e14519486f.tar.gz spark-05f652d6c2bbd764a1dd5a45301811e14519486f.tar.bz2 spark-05f652d6c2bbd764a1dd5a45301811e14519486f.zip |
[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.
- star is not allowed to use in the select list when users specify ordinals in group by
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.
Author: gatorsmile <gatorsmile@gmail.com>
Author: xiaoli <lixiao1983@gmail.com>
Author: Xiao Li <xiaoli@Xiaos-MacBook-Pro.local>
Closes #11846 from gatorsmile/groupByOrdinal.
Diffstat (limited to 'R/pkg/inst/tests/testthat/test_take.R')
0 files changed, 0 insertions, 0 deletions