spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yhuai <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-9830] [SQL] Remove AggregateExpression1...
Date Tue, 10 Nov 2015 01:46:56 GMT
Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9556#discussion_r44361188
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/expressions/WindowSpec.scala ---
    @@ -141,40 +141,56 @@ class WindowSpec private[sql](
        */
       private[sql] def withAggregate(aggregate: Column): Column = {
         val windowExpr = aggregate.expr match {
    -      case Average(child) => WindowExpression(
    -        UnresolvedWindowFunction("avg", child :: Nil),
    -        WindowSpecDefinition(partitionSpec, orderSpec, frame))
    -      case Sum(child) => WindowExpression(
    -        UnresolvedWindowFunction("sum", child :: Nil),
    -        WindowSpecDefinition(partitionSpec, orderSpec, frame))
    -      case Count(child) => WindowExpression(
    -        UnresolvedWindowFunction("count", child :: Nil),
    -        WindowSpecDefinition(partitionSpec, orderSpec, frame))
    -      case First(child, ignoreNulls) => WindowExpression(
    -        // TODO this is a hack for Hive UDAF first_value
    -        UnresolvedWindowFunction(
    -          "first_value",
    -          child :: ignoreNulls :: Nil),
    -        WindowSpecDefinition(partitionSpec, orderSpec, frame))
    -      case Last(child, ignoreNulls) => WindowExpression(
    -        // TODO this is a hack for Hive UDAF last_value
    -        UnresolvedWindowFunction(
    -          "last_value",
    -          child :: ignoreNulls :: Nil),
    -        WindowSpecDefinition(partitionSpec, orderSpec, frame))
    -      case Min(child) => WindowExpression(
    -        UnresolvedWindowFunction("min", child :: Nil),
    -        WindowSpecDefinition(partitionSpec, orderSpec, frame))
    -      case Max(child) => WindowExpression(
    -        UnresolvedWindowFunction("max", child :: Nil),
    -        WindowSpecDefinition(partitionSpec, orderSpec, frame))
    -      case wf: WindowFunction => WindowExpression(
    -        wf,
    -        WindowSpecDefinition(partitionSpec, orderSpec, frame))
    +      // First, we check if we get an aggregate function without the DISTINCT keyword.
    +      // Right now, we do not support using a DISTINCT aggregate function as a
    +      // window function.
    +      case AggregateExpression(aggregateFunction, _, isDistinct) if !isDistinct =>
    +        aggregateFunction match {
    +          case Average(child) => WindowExpression(
    +            UnresolvedWindowFunction("avg", child :: Nil),
    +            WindowSpecDefinition(partitionSpec, orderSpec, frame))
    +          case Sum(child) => WindowExpression(
    +            UnresolvedWindowFunction("sum", child :: Nil),
    +            WindowSpecDefinition(partitionSpec, orderSpec, frame))
    +          case Count(child) => WindowExpression(
    +            UnresolvedWindowFunction("count", child :: Nil),
    +            WindowSpecDefinition(partitionSpec, orderSpec, frame))
    +          case First(child, ignoreNulls) => WindowExpression(
    +            // TODO this is a hack for Hive UDAF first_value
    +            UnresolvedWindowFunction(
    +              "first_value",
    +              child :: ignoreNulls :: Nil),
    +            WindowSpecDefinition(partitionSpec, orderSpec, frame))
    +          case Last(child, ignoreNulls) => WindowExpression(
    +            // TODO this is a hack for Hive UDAF last_value
    +            UnresolvedWindowFunction(
    +              "last_value",
    +              child :: ignoreNulls :: Nil),
    +            WindowSpecDefinition(partitionSpec, orderSpec, frame))
    +          case Min(child) => WindowExpression(
    +            UnresolvedWindowFunction("min", child :: Nil),
    +            WindowSpecDefinition(partitionSpec, orderSpec, frame))
    +          case Max(child) => WindowExpression(
    +            UnresolvedWindowFunction("max", child :: Nil),
    +            WindowSpecDefinition(partitionSpec, orderSpec, frame))
    +          case x =>
    +            throw new UnsupportedOperationException(s"$x is not supported in window operation.")
    --- End diff --
    
    Done


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

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


Mime
View raw message