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

    https://github.com/apache/spark/pull/21912#discussion_r209862522
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
 ---
    @@ -3330,50 +3136,123 @@ case class ArrayRemove(left: Expression, right: 
Expression)
         val pos = ctx.freshName("pos")
         val getValue = CodeGenerator.getValue(inputArray, elementType, i)
         val isEqual = ctx.genEqual(elementType, value, getValue)
    -    if (!CodeGenerator.isPrimitiveType(elementType)) {
    -      val arrayClass = classOf[GenericArrayData].getName
    +
    +    val (allocation, setFunc) =
    +      ctx.createArrayData(values, elementType, newArraySize, s" 
$prettyName failed.")
    +    val assignment = ctx.createArrayAssignment(
    +      values, dataType, elementType, inputArray, setFunc, checkForNull = 
Some(false))
    +
    +    s"""
    +       |$allocation
    +       |int $pos = 0;
    +       |for (int $i = 0; $i < $inputArray.numElements(); $i ++) {
    +       |  if ($inputArray.isNullAt($i)) {
    +       |    $values.setNullAt($pos);
    +       |    $pos = $pos + 1;
    +       |  }
    +       |  else {
    +       |    if (!($isEqual)) {
    +       |      ${assignment(pos, i)}
    +       |      $pos = $pos + 1;
    +       |    }
    +       |  }
    +       |}
    +       |${ev.value} = $values;
    +     """.stripMargin
    +  }
    +
    +  override def prettyName: String = "array_remove"
    +}
    +
    +/**
    + * Will become common base class for [[ArrayDistinct]], [[ArrayUnion]], 
[[ArrayIntersect]],
    + * and [[ArrayExcept]].
    + */
    +trait ArraySetLike {
    +  @transient protected lazy val dt: DataType = NullType
    +  @transient protected lazy val et: DataType = NullType
    --- End diff --
    
    How about: `protected def dt: ArrayType` and `protected def et: DataType`?


---

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

Reply via email to