You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "navinvishy (via GitHub)" <gi...@apache.org> on 2023/01/28 04:53:58 UTC
[GitHub] [spark] navinvishy commented on a diff in pull request #38947: [SPARK-41233][SQL] Add `array_prepend` function
navinvishy commented on code in PR #38947:
URL: https://github.com/apache/spark/pull/38947#discussion_r1089643942
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollectionExpressionsSuite.scala:
##########
@@ -1840,6 +1840,47 @@ class CollectionExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper
checkEvaluation(ArrayRepeat(Literal("hi"), Literal(null, IntegerType)), null)
}
+ test("SPARK-41233: ArrayPrepend") {
+ val a0 = Literal.create(Seq(1, 2, 3, 4), ArrayType(IntegerType))
+ val a1 = Literal.create(Seq("a", "b", "c"), ArrayType(StringType))
+ val a2 = Literal.create(Seq.empty[Integer], ArrayType(IntegerType))
+ val a3 = Literal.create(null, ArrayType(StringType))
+
+ checkEvaluation(ArrayPrepend(a0, Literal(0)), Seq(0, 1, 2, 3, 4))
+ checkEvaluation(ArrayPrepend(a1, Literal("a")), Seq("a", "a", "b", "c"))
+ checkEvaluation(ArrayPrepend(a2, Literal(1)), Seq(1))
+ checkEvaluation(ArrayPrepend(a2, Literal(null, IntegerType)), null)
Review Comment:
@zhengruifeng sorry about the delay here. I've updated this to reflect the behavior you mentioned. Fixed the tests to show that as well. Thanks!
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org