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

    https://github.com/apache/spark/pull/16986#discussion_r120010289
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
 ---
    @@ -652,6 +653,299 @@ case class MapObjects private(
       }
     }
     
    +object CollectObjectsToMap {
    +  private val curId = new java.util.concurrent.atomic.AtomicInteger()
    +
    +  /**
    +   * Construct an instance of CollectObjects case class.
    +   *
    +   * @param keyFunction The function applied on the key collection 
elements.
    +   * @param keyInputData An expression that when evaluated returns a key 
collection object.
    +   * @param keyElementType The data type of key elements in the collection.
    +   * @param valueFunction The function applied on the value collection 
elements.
    +   * @param valueInputData An expression that when evaluated returns a 
value collection object.
    +   * @param valueElementType The data type of value elements in the 
collection.
    +   * @param collClass The type of the resulting collection.
    +   */
    +  def apply(
    +      keyFunction: Expression => Expression,
    +      keyInputData: Expression,
    +      keyElementType: DataType,
    +      valueFunction: Expression => Expression,
    +      valueInputData: Expression,
    +      valueElementType: DataType,
    +      collClass: Class[_]): CollectObjectsToMap = {
    +    val id = curId.getAndIncrement()
    +    val keyLoopValue = s"CollectObjectsToMap_keyLoopValue$id"
    +    val keyLoopIsNull = s"CollectObjectsToMap_keyLoopIsNull$id"
    +    val keyLoopVar = LambdaVariable(keyLoopValue, keyLoopIsNull, 
keyElementType)
    +    val valueLoopValue = s"CollectObjectsToMap_valueLoopValue$id"
    +    val valueLoopIsNull = s"CollectObjectsToMap_valueLoopIsNull$id"
    +    val valueLoopVar = LambdaVariable(valueLoopValue, valueLoopIsNull, 
valueElementType)
    +    val tupleLoopVar = s"CollectObjectsToMap_tupleLoopValue$id"
    +    val builderValue = s"CollectObjectsToMap_builderValue$id"
    +    CollectObjectsToMap(
    +      keyLoopValue, keyLoopIsNull, keyElementType, 
keyFunction(keyLoopVar), keyInputData,
    +      valueLoopValue, valueLoopIsNull, valueElementType, 
valueFunction(valueLoopVar),
    +      valueInputData,
    +      tupleLoopVar, collClass, builderValue)
    +  }
    +}
    +
    +/**
    + * An equivalent to the [[MapObjects]] case class but returning an 
ObjectType containing
    + * a Scala collection constructed using the associated builder, obtained 
by calling `newBuilder`
    + * on the collection's companion object.
    + *
    + * @param keyLoopValue the name of the loop variable that is used when 
iterating over the key
    + *                     collection, and which is used as input for the 
`keyLambdaFunction`
    + * @param keyLoopIsNull the nullability of the loop variable that is used 
when iterating over
    + *                      the key collection, and which is used as input for 
the `keyLambdaFunction`
    + * @param keyLoopVarDataType the data type of the loop variable that is 
used when iterating over
    + *                           the key collection, and which is used as 
input for the
    + *                           `keyLambdaFunction`
    + * @param keyLambdaFunction A function that takes the `keyLoopVar` as 
input, and is used as
    + *                          a lambda function to handle collection 
elements.
    + * @param keyInputData An expression that when evaluated returns a 
collection object.
    + * @param valueLoopValue the name of the loop variable that is used when 
iterating over the value
    + *                       collection, and which is used as input for the 
`valueLambdaFunction`
    + * @param valueLoopIsNull the nullability of the loop variable that is 
used when iterating over
    + *                        the value collection, and which is used as input 
for the
    + *                        `valueLambdaFunction`
    + * @param valueLoopVarDataType the data type of the loop variable that is 
used when iterating over
    + *                             the value collection, and which is used as 
input for the
    + *                             `valueLambdaFunction`
    + * @param valueLambdaFunction A function that takes the `valueLoopVar` as 
input, and is used as
    + *                            a lambda function to handle collection 
elements.
    + * @param valueInputData An expression that when evaluated returns a 
collection object.
    + * @param tupleLoopValue the name of the loop variable that holds the 
tuple to be added to the
    +  *                      resulting map (used only for Scala Map)
    + * @param collClass The type of the resulting collection.
    + * @param builderValue The name of the builder variable used to construct 
the resulting collection.
    + */
    +case class CollectObjectsToMap private(
    +    keyLoopValue: String,
    +    keyLoopIsNull: String,
    +    keyLoopVarDataType: DataType,
    --- End diff --
    
    I modelled this class after the `MapObjects` class so that they could be 
used similarly. I noticed that since then a new `UnresolvedMapObjects` class 
was introduced which also doesn't require the element data type. Would this be 
something similar? And if so, shouldn't I rather introduce a new 
`UnresolvedCollectObjectsToMap` class instead?


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