GitHub user dilipbiswal opened a pull request:
https://github.com/apache/spark/pull/13045
[SPARK-15114][SQL] Column name generated by typed aggregate is super verbose
## What changes were proposed in this pull request?
Generate a shorter default alias for `AggregateExpression `, In this PR,
aggregate function name along with a index is used for generating the alias
name.
```SQL
val ds = Seq(1, 3, 2, 5).toDS()
ds.select(typed.sum((i: Int) => i), typed.avg((i: Int) => i)).show()
```
Output before change.
```SQL
+-----------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
|typedsumdouble(unresolveddeserializer(upcast(input[0, int], IntegerType, -
root class: "scala.Int"), value#1),
upcast(value))|typedaverage(unresolveddeserializer(upcast(input[0, int],
IntegerType, - root class: "scala.Int"), value#1), newInstance(class
scala.Tuple2))|
+-----------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
|
11.0|
2.75|
+-----------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
```
Output after change:
```SQL
+-----------------+---------------+
|typedsumdouble_c1|typedaverage_c2|
+-----------------+---------------+
| 11.0| 2.75|
+-----------------+---------------+
```
Note: There is one test in ParquetSuites.scala which shows that that the
system picked alias
name is not usable and is rejected.
[test](https://github.com/apache/spark/blob/master/sql/hive/src/test/scala/org/apache/spark/sql/hive/parquetSuites.scala#L672-#L687)
## How was this patch tested?
A new test was added in DataSetAggregatorSuite.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dilipbiswal/spark spark-15114
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/13045.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 #13045
----
commit 65375b41605ebe8d506a11e255ee5b1efa54e36d
Author: Dilip Biswal <[email protected]>
Date: 2016-05-10T23:33:30Z
[SPARK-15114] Column name generated by typed aggregate is super verbose
----
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]