Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5290#discussion_r31692885
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -364,11 +364,24 @@ class Analyzer(
     
             val (resolvedOrdering, missing) = resolveAndFindMissing(ordering, 
a, groupingRelation)
     
    -        if (missing.nonEmpty) {
    +        val addForAlias = new ArrayBuffer[NamedExpression]()
    +        val aliasedOrdering = resolvedOrdering.zipWithIndex.map {
    +          case (o, i) => {
    +            o transform {
    +              case aggOrSub @ (_: AggregateExpression | _: Substring) =>
    --- End diff --
    
    It's another bug and not only affect `Substring`... I tried `SELECT b + 1, 
count(*) FROM orderByData GROUP BY b + 1 ORDER BY b + 1` and also failed. The 
key problem is we build the temp grouping relation by `grouping.collect { case 
ne: NamedExpression => ne.toAttribute }` which filter out all un-named 
expressions like `Add`, `Substring`, etc. I will work on it.
    cc @marmbrus @rxin 



---
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]

Reply via email to