Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/7537#discussion_r35125100
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ComplexTypeSuite.scala
---
@@ -117,6 +117,22 @@ class ComplexTypeSuite extends SparkFunSuite with
ExpressionEvalHelper {
checkEvaluation(getArrayStructFields(nullArrayStruct, "a"), null)
}
+ test("CreateArray") {
+ val intSeq = Seq(5, 10, 15, 20, 25)
+ val longSeq = intSeq.map(_.toLong)
+ val strSeq = intSeq.map(_.toString)
+ checkEvaluation(CreateArray(intSeq.map(Literal(_))), intSeq, EmptyRow)
+ checkEvaluation(CreateArray(longSeq.map(Literal(_))), longSeq,
EmptyRow)
+ checkEvaluation(CreateArray(strSeq.map(Literal(_))), strSeq, EmptyRow)
+
+ val intWithNull = intSeq.map(Literal(_)).+:(Literal.create(null,
IntegerType))
+ val longWithNull = longSeq.map(Literal(_)).+:(Literal.create(null,
LongType))
+ val strWithNull = strSeq.map(Literal(_)).+:(Literal.create(null,
StringType))
+ checkEvaluation(CreateArray(intWithNull), intSeq.+:(null), EmptyRow)
+ checkEvaluation(CreateArray(longWithNull), longSeq.+:(null), EmptyRow)
+ checkEvaluation(CreateArray(strWithNull), strSeq.+:(null), EmptyRow)
--- End diff --
Sorry to nit-pick, but what is happening here is kind of confusing:
```scala
scala> List(1,2).+:(null)
res0: List[Any] = List(null, 1, 2)
```
Perhaps just use infix notation for operators:
```scala
scala> List(1,2) :+ null
res1: List[Any] = List(1, 2, null)
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]