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

    https://github.com/apache/spark/pull/22045#discussion_r210470513
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala
 ---
    @@ -497,6 +497,53 @@ case class ArrayAggregate(
       override def prettyName: String = "aggregate"
     }
     
    +/**
    + * Returns a map that applies the function to each value of the map.
    + */
    +@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) -> v + 
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(
    +    argument: Expression,
    +    function: Expression)
    +  extends MapBasedSimpleHigherOrderFunction with CodegenFallback {
    +
    +  override def nullable: Boolean = argument.nullable
    +
    +  @transient lazy val MapType(keyType, valueType, valueContainsNull) = 
argument.dataType
    +
    +  override def dataType: DataType = MapType(keyType, function.dataType, 
valueContainsNull)
    +
    +  override def bind(f: (Expression, Seq[(DataType, Boolean)]) => 
LambdaFunction)
    +  : TransformValues = {
    +    copy(function = f(function, (keyType, false) :: (valueType, 
valueContainsNull) :: Nil))
    +  }
    +
    +  @transient lazy val LambdaFunction(
    +  _, (keyVar: NamedLambdaVariable) :: (valueVar: NamedLambdaVariable) :: 
Nil, _) = function
    --- End diff --
    
    nit: indent


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to