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

    https://github.com/apache/spark/pull/19872#discussion_r154644340
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/RelationalGroupedDataset.scala ---
    @@ -437,6 +437,37 @@ class RelationalGroupedDataset protected[sql](
               df.logicalPlan))
       }
     
    +
    +  private[sql] def aggInPandas(columns: Seq[Column]): DataFrame = {
    +    val exprs = columns.map(column => column.expr.asInstanceOf[PythonUDF])
    +
    +    val groupingNamedExpressions = groupingExprs.map {
    +      case ne: NamedExpression => ne
    +      case other => Alias(other, other.toString)()
    +    }
    +
    +    val groupingAttributes = groupingNamedExpressions.map(_.toAttribute)
    +
    +    val child = df.logicalPlan
    +
    +    val childrenExpressions = exprs.flatMap(expr =>
    +      expr.children.map {
    +      case ne: NamedExpression => ne
    +      case other => Alias(other, other.toString)()
    +    })
    +
    +    val project = Project(groupingNamedExpressions ++ childrenExpressions, 
child)
    +
    +    val udfOutputs = exprs.flatMap(expr =>
    +      Seq(AttributeReference(expr.name, expr.dataType)())
    +    )
    --- End diff --
    
    I think this could be inlined.


---

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

Reply via email to