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

    https://github.com/apache/spark/pull/21034#discussion_r180686345
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
 ---
    @@ -212,6 +213,96 @@ case class SortArray(base: Expression, ascendingOrder: 
Expression)
       override def prettyName: String = "sort_array"
     }
     
    +/**
    + * Returns a reversed string or an array with reverse order of elements.
    + */
    +@ExpressionDescription(
    +  usage = "_FUNC_(array) - Returns a reversed string or an array with 
reverse order of elements.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_('Spark SQL');
    +       LQS krapS
    +      > SELECT _FUNC_(array(2, 1, 4, 3));
    +       [3, 4, 1, 2]
    +  """,
    +  since = "2.4.0")
    +case class Reverse(child: Expression) extends UnaryExpression with 
ImplicitCastInputTypes {
    +
    +  // Input types are utilized by type coercion in ImplicitTypeCasts.
    +  override def inputTypes: Seq[AbstractDataType] = Seq(StringType)
    +
    +  val allowedTypes = Seq(StringType, ArrayType)
    +
    +  override def dataType: DataType = child.dataType
    +
    +  lazy val elementType: DataType = 
dataType.asInstanceOf[ArrayType].elementType
    +
    +  override def checkInputDataTypes(): TypeCheckResult = {
    --- End diff --
    
    Great idea!


---

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

Reply via email to