Github user gatorsmile commented on the pull request:
https://github.com/apache/spark/pull/11298#issuecomment-187005048
##### Issue 2: mixture of aliases and real columns in order by clause
```SQL
SELECT key as k, value as v, sum(value) FROM src GROUP BY key, value ORDER
BY k, value
```
```
== Parsed Logical Plan ==
'Sort ['k ASC,'value ASC], true
+- 'Aggregate ['key,'value], [unresolvedalias('key AS
k#47,None),unresolvedalias('value AS
v#48,None),unresolvedalias('sum('value),None)]
+- 'UnresolvedRelation `src`, None
```
In the above case, we need to replace the actual column name `value` by the
alias name `v`. Otherwise, we have to introduce `k` in all the nodes between
`Sort` and `Aggregate`.
```
Project [k#47,v#48,_c2#54L]
+- Sort [k#47 ASC,v#48 ASC], true
+- Aggregate [key#45,value#46], [key#45 AS k#47,value#46 AS
v#48,(sum(cast(value#46 as bigint)),mode=Complete,isDistinct=false) AS _c2#54L]
+- Subquery src
+- Project [_1#43 AS key#45,_2#44 AS value#46]
+- LocalRelation [_1#43,_2#44], [[1,1],[-1,1]]
```
---
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]