Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16986#discussion_r121265420
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
 ---
    @@ -652,6 +652,177 @@ case class MapObjects private(
       }
     }
     
    +object CollectObjectsToMap {
    +  private val curId = new java.util.concurrent.atomic.AtomicInteger()
    +
    +  /**
    +   * Construct an instance of CollectObjectsToMap case class.
    +   *
    +   * @param keyFunction The function applied on the key collection 
elements.
    +   * @param valueFunction The function applied on the value collection 
elements.
    +   * @param inputData An expression that when evaluated returns a map 
object.
    +   * @param collClass The type of the resulting collection.
    +   */
    +  def apply(
    +      keyFunction: Expression => Expression,
    +      valueFunction: Expression => Expression,
    +      inputData: Expression,
    +      collClass: Class[_]): CollectObjectsToMap = {
    +    val id = curId.getAndIncrement()
    +    val keyLoopValue = s"CollectObjectsToMap_keyLoopValue$id"
    +    val mapType = inputData.dataType.asInstanceOf[MapType]
    +    val keyLoopVar = LambdaVariable(keyLoopValue, "", mapType.keyType, 
nullable = false)
    +    val valueLoopValue = s"CollectObjectsToMap_valueLoopValue$id"
    +    val valueLoopIsNull = s"CollectObjectsToMap_valueLoopIsNull$id"
    +    val valueLoopVar = LambdaVariable(valueLoopValue, valueLoopIsNull, 
mapType.valueType)
    +    CollectObjectsToMap(
    +      keyLoopValue, keyFunction(keyLoopVar),
    +      valueLoopValue, valueLoopIsNull, valueFunction(valueLoopVar),
    +      inputData, collClass)
    +  }
    +}
    +
    +/**
    + * An equivalent to the [[MapObjects]] case class but returning an 
ObjectType containing
    --- End diff --
    
    let's update the class doc to explicitly say that this expression is used 
to convert a catalyst map to external map.


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