Github user mn-mikke commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22045#discussion_r208751629
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala
 ---
    @@ -442,3 +442,61 @@ case class ArrayAggregate(
     
       override def prettyName: String = "aggregate"
     }
    +
    +/**
    + * Transform Values for every entry of the map by applying 
transform_values function.
    + * Returns map wth transformed values
    + */
    +@ExpressionDescription(
    +usage = "_FUNC_(expr, func) - Transforms values in the map using the 
function.",
    +examples = """
    +    Examples:
    +       > SELECT _FUNC_(map(array(1, 2, 3), array(1, 2, 3), (k,v) -> k + 1);
    +        map(array(1, 2, 3), array(2, 3, 4))
    +       > SELECT _FUNC_(map(array(1, 2, 3), array(1, 2, 3), (k, v) -> k + 
v);
    +        map(array(1, 2, 3), array(2, 4, 6))
    +  """,
    +since = "2.4.0")
    +case class TransformValues(
    +    input: Expression,
    +    function: Expression)
    +  extends MapBasedSimpleHigherOrderFunction with CodegenFallback {
    +
    +  override def nullable: Boolean = input.nullable
    +
    +  override def dataType: DataType = {
    +    val map = input.dataType.asInstanceOf[MapType]
    +    MapType(map.keyType, function.dataType, map.valueContainsNull)
    +  }
    +
    +  override def inputTypes: Seq[AbstractDataType] = Seq(MapType, 
expectingFunctionType)
    +
    +  @transient val (keyType, valueType, valueContainsNull) =
    +    HigherOrderFunction.mapKeyValueArgumentType(input.dataType)
    +
    +  override def bind(f: (Expression, Seq[(DataType, Boolean)]) => 
LambdaFunction):
    --- End diff --
    
    nit: formatting


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to