Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15101#discussion_r78913008
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
 ---
    @@ -1098,9 +1098,16 @@ object ReplaceExceptWithAntiJoin extends 
Rule[LogicalPlan] {
      */
     object RemoveLiteralFromGroupExpressions extends Rule[LogicalPlan] {
       def apply(plan: LogicalPlan): LogicalPlan = plan transform {
    -    case a @ Aggregate(grouping, _, _) =>
    +    case a @ Aggregate(grouping, _, _) if grouping.nonEmpty =>
           val newGrouping = grouping.filter(!_.foldable)
    -      a.copy(groupingExpressions = newGrouping)
    +      if (newGrouping.nonEmpty) {
    +        a.copy(groupingExpressions = newGrouping)
    +      } else {
    +        // Do not rewrite the aggregate if we drop all grouping 
expressions, because this can
    +        // change the return semantics when the input of the Aggregate is 
empty. See SPARK-17114
    +        // for more information.
    +        a
    --- End diff --
    
    Then it might be even better to replace it with something that is trivial 
to hash.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to