Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/10731#discussion_r56752434
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
@@ -497,6 +498,41 @@ class Analyzer(
ordering.map(order => resolveExpression(order,
child).asInstanceOf[SortOrder])
Sort(newOrdering, global, child)
+ // Replace the index with the related attribute for ORDER BY
+ // which is a 1-base position of the projection list.
+ case s @ Sort(orders, global, child) if child.resolved &&
--- End diff --
I am unable to find a good place for `group by ordinal resolution`, after
placing `order by ordinal resolution` in `ResolveSortReferences`. Two options
are in my mind:
- Assuming we can merge https://github.com/apache/spark/pull/11208, which
splits `ResolveReferences` to two rules: `ResolveStar` and `ResolveReferences`.
Then, `ResolveReferences` is not very long, maybe we can keep resolution of
ordinal here.
- Create a separate rule `ResolveOrdinal` for both cases.
In the next PR, I will first pick the second option, if nobody is against
it. : ) Thanks!
---
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]