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

    https://github.com/apache/spark/pull/16758#discussion_r99749020
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/object.scala
 ---
    @@ -313,6 +313,56 @@ case class MapGroups(
         outputObjAttr: Attribute,
         child: LogicalPlan) extends UnaryNode with ObjectProducer
     
    +/** Internal class representing State */
    +trait LogicalKeyedState[S]
    +
    +/** Factory for constructing new `MapGroupsWithState` nodes. */
    +object MapGroupsWithState {
    +  def apply[K: Encoder, V: Encoder, S: Encoder, U: Encoder](
    +      func: (Any, Iterator[Any], LogicalKeyedState[Any]) => Iterator[Any],
    +      groupingAttributes: Seq[Attribute],
    +      dataAttributes: Seq[Attribute],
    +      child: LogicalPlan): LogicalPlan = {
    +    val mapped = new MapGroupsWithState(
    +      func,
    +      UnresolvedDeserializer(encoderFor[K].deserializer, 
groupingAttributes),
    +      UnresolvedDeserializer(encoderFor[V].deserializer, dataAttributes),
    +      groupingAttributes,
    +      dataAttributes,
    +      CatalystSerde.generateObjAttr[U],
    +      encoderFor[S].resolveAndBind().deserializer,
    +      encoderFor[S].namedExpressions,
    +      child)
    +    CatalystSerde.serialize[U](mapped)
    +  }
    +}
    +
    +/**
    + * Applies func to each unique group in `child`, based on the evaluation 
of `groupingAttributes`,
    + * while using state data.
    + * Func is invoked with an object representation of the grouping key an 
iterator containing the
    + * object representation of all the rows with that key.
    + *
    + * @param keyDeserializer used to extract the key object for each group.
    + * @param valueDeserializer used to extract the items in the iterator from 
an input row.
    + * @param groupingAttributes used to group the data
    + * @param dataAttributes used to read the data
    + * @param outputObjAttr used to define the output object
    + * @param stateDeserializer used to deserialize state before calling `func`
    + * @param stateSerializer used to serialize updated state after calling 
`func`
    + */
    +case class MapGroupsWithState(
    +    func: (Any, Iterator[Any], LogicalKeyedState[Any]) => Iterator[Any],
    +    keyDeserializer: Expression,
    +    valueDeserializer: Expression,
    +    groupingAttributes: Seq[Attribute],
    +    dataAttributes: Seq[Attribute],
    +    outputObjAttr: Attribute,
    +    stateDeserializer: Expression,
    +    stateSerializer: Seq[NamedExpression],
    +    child: LogicalPlan) extends UnaryNode with ObjectProducer
    +
    +
    --- End diff --
    
    removed


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