cloud-fan commented on code in PR #40563: URL: https://github.com/apache/spark/pull/40563#discussion_r1155722493
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala: ########## @@ -5056,128 +4950,45 @@ case class ArrayCompact(child: Expression) """, since = "3.4.0", group = "array_funcs") -case class ArrayAppend(left: Expression, right: Expression) - extends BinaryExpression - with ImplicitCastInputTypes - with ComplexTypeMergingExpression - with QueryErrorsBase { - override def prettyName: String = "array_append" +case class ArrayAppend(left: Expression, right: Expression) extends InsertArrayOneSide { - @transient protected lazy val elementType: DataType = - inputTypes.head.asInstanceOf[ArrayType].elementType + override lazy val replacement: Expression = + ArrayInsert(left, Add(ArraySize(left), Literal(1)), right) Review Comment: A risk is `left` can be evaluated twice if common subexpression elimination is disabled, or the underlying execution engine (native engine) does not support it. I'd prefer to keep `ArrayAppend` as it is, or update `ArrayInsert` to provide an easy way to do append. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org