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

    https://github.com/apache/spark/pull/12836#discussion_r66745283
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/objects.scala ---
    @@ -325,6 +330,71 @@ case class MapGroupsExec(
     }
     
     /**
    + * Groups the input rows together and calls the R function with each group 
and an iterator
    + * containing all elements in the group.
    + * The result of this function is flattened before being output.
    + */
    +case class FlatMapGroupsInRExec(
    +    func: Array[Byte],
    +    packageNames: Array[Byte],
    +    broadcastVars: Array[Broadcast[Object]],
    +    inputSchema: StructType,
    +    outputSchema: StructType,
    +    keyDeserializer: Expression,
    +    valueDeserializer: Expression,
    +    groupingAttributes: Seq[Attribute],
    +    dataAttributes: Seq[Attribute],
    +    outputObjAttr: Attribute,
    +    child: SparkPlan) extends UnaryExecNode with ObjectProducerExec {
    +
    +  override def output: Seq[Attribute] = outputObjAttr :: Nil
    +  override def producedAttributes: AttributeSet = 
AttributeSet(outputObjAttr)
    +
    +  override def requiredChildDistribution: Seq[Distribution] =
    +    ClusteredDistribution(groupingAttributes) :: Nil
    +
    +  override def requiredChildOrdering: Seq[Seq[SortOrder]] =
    +    Seq(groupingAttributes.map(SortOrder(_, Ascending)))
    +
    +  override protected def doExecute(): RDD[InternalRow] = {
    +    val isSerializedRData =
    +      if (outputSchema == SERIALIZED_R_DATA_SCHEMA) true else false
    +    val serializerForR = if (!isSerializedRData) {
    +      SerializationFormats.ROW
    +    } else {
    +      SerializationFormats.BYTE
    +    }
    +
    +    child.execute().mapPartitionsInternal { iter =>
    +      val grouped = GroupedIterator(iter, groupingAttributes, child.output)
    +      val getKey = ObjectOperator.deserializeRowToObject(keyDeserializer, 
groupingAttributes)
    +      val getValue = 
ObjectOperator.deserializeRowToObject(valueDeserializer, dataAttributes)
    +      val outputObject = 
ObjectOperator.wrapObjectToRow(outputObjAttr.dataType)
    +      val runner = new RRunner[Array[Byte]](
    +        func, SerializationFormats.ROW, serializerForR, packageNames, 
broadcastVars,
    +        isDataFrame = true, colNames = inputSchema.fieldNames, mode = 2)
    +
    +      val groupedRBytes = grouped.flatMap { case (key, rowIter) =>
    --- End diff --
    
    Hi @sun-rui, I did it similar to: 
https://github.com/NarineK/spark/blob/d51441f704e2abad7f7a3cc829664cd201b0fcd2/sql/core/src/main/scala/org/apache/spark/sql/execution/objects.scala#L322
    
    I we can also use map here. If there is no nested content flatmap will 
perform like map. In general for dataframe rows, can someone have a row of rows 
?


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