-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-10437][SQL] Support aggregation expressions in Order By #8599
Conversation
Test build #41996 has finished for PR 8599 at commit
|
@@ -561,7 +561,7 @@ class Analyzer( | |||
} | |||
|
|||
case sort @ Sort(sortOrder, global, aggregate: Aggregate) | |||
if aggregate.resolved && !sort.resolved => | |||
if aggregate.resolved => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to set up a stop condition for this rule, or something like SELECT a, SUM(b) FROM t GROUP BY a ORDER BY a
will go through this rule again and again until reach the fixed point. How about changing the end of this rule to:
if (evaluatedOrderings == sortOrder) {
sort
} else {
Project(aggregate.output,
Sort(evaluatedOrderings, global,
aggregate.copy(aggregateExpressions = originalAggExprs ++ needsPushDown)))
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've updated it.
Test build #42003 has finished for PR 8599 at commit
|
LGTM except a minor comment for test. |
Test build #42036 has finished for PR 8599 at commit
|
retest this please. |
Test build #42038 has finished for PR 8599 at commit
|
Test build #42040 has finished for PR 8599 at commit
|
retest this please. |
1 similar comment
retest this please. |
Test build #42057 has finished for PR 8599 at commit
|
ping @liancheng |
ping @liancheng @marmbrus |
|GROUP BY a | ||
|ORDER BY count(*) | ||
""".stripMargin), | ||
Row(2) :: Row(2) :: Row(2) :: Row(2) :: Nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: And also add more typical unit tests like:
"""
|SELECT a
|FROM orderByData
|GROUP BY a
|ORDER BY a, count(*), sum(b)
""".stripMargin),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've added it.
Test build #42186 has finished for PR 8599 at commit
|
|
@liancheng Updated. Thanks. |
@liancheng Any more comment? |
Thanks, merged to master. |
JIRA: https://issues.apache.org/jira/browse/SPARK-10437
If an expression in
SortOrder
is a resolved one, such ascount(1)
, the corresponding rule inAnalyzer
to make it work in order by will not be applied.