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

    https://github.com/apache/spark/pull/17224#discussion_r105327492
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -524,15 +529,21 @@ class Analyzer(
                 def ifExpr(expr: Expression) = {
                   If(EqualTo(pivotColumn, value), expr, Literal(null))
                 }
    +            def ifNullSafeExpr(expr: Expression) = {
    +              If(EqualNullSafe(pivotColumn, value), expr, Literal(null))
    +            }
                 aggregates.map { aggregate =>
                   val filteredAggregate = aggregate.transformDown {
                     // Assumption is the aggregate function ignores nulls. 
This is true for all current
    -                // AggregateFunction's with the exception of First and 
Last in their default mode
    -                // (which we handle) and possibly some Hive UDAF's.
    +                // AggregateFunction's with the exception of First, Last 
and Count in their
    +                // default mode (which we handle) and possibly some Hive 
UDAF's.
                     case First(expr, _) =>
                       First(ifExpr(expr), Literal(true))
                     case Last(expr, _) =>
                       Last(ifExpr(expr), Literal(true))
    +                case c: Count =>
    +                  // In case of count, `null` should be counted.
    +                  c.withNewChildren(c.children.map(ifNullSafeExpr))
    --- End diff --
    
    Let me update this path as soon as we decide what we want in another PR for 
this JIRA.


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