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

    https://github.com/apache/spark/pull/21050#discussion_r189149082
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
 ---
    @@ -1059,3 +1059,96 @@ case class Flatten(child: Expression) extends 
UnaryExpression {
     
       override def prettyName: String = "flatten"
     }
    +
    +/**
    + * Removes duplicate values from the array.
    + */
    +@ExpressionDescription(
    +  usage = "_FUNC_(array) - Removes duplicate values from the array.",
    +  examples = """
    +    Examples:
    +      > SELECT _FUNC_(array(1, 2, 3, null, 3));
    +       [1,2,3,null]
    +  """, since = "2.4.0")
    +case class ArrayDistinct(child: Expression)
    +  extends UnaryExpression with ExpectsInputTypes {
    +
    +  override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType)
    +
    +  override def dataType: DataType = child.dataType
    +
    +  override def nullSafeEval(array: Any): Any = {
    +    val elementType = child.dataType.asInstanceOf[ArrayType].elementType
    +    val data = 
array.asInstanceOf[ArrayData].toArray[AnyRef](elementType).distinct
    --- End diff --
    
    Yes, distinct keeps the order.


---

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

Reply via email to