liuyongvs commented on code in PR #3260:
URL: https://github.com/apache/calcite/pull/3260#discussion_r1230398603
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5334,6 +5334,33 @@ private static void checkIf(SqlOperatorFixture f) {
f.checkScalar("rand_integer(2, 11)", 1, "INTEGER NOT NULL");
}
+ /** Tests {@code ARRAY_APPEND} function from Spark. */
+ @Test void testArrayAppendFunc() {
+ final SqlOperatorFixture f0 = fixture();
+ f0.setFor(SqlLibraryOperators.ARRAY_APPEND);
+ f0.checkFails("^array_append(array[1], 2)^",
+ "No match found for function signature ARRAY_APPEND\\("
+ + "<INTEGER ARRAY>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.SPARK);
+ f.checkScalar("array_append(array[1], 2)", "[1, 2]",
+ "INTEGER NOT NULL ARRAY NOT NULL");
+ f.checkScalar("array_append(array[1], null)", "[1, null]",
+ "INTEGER ARRAY NOT NULL");
+ f.checkScalar("array_append(array(null), null)", "[null, null]",
+ "NULL ARRAY NOT NULL");
+ f.checkScalar("array_append(array(), null)", "[null]",
Review Comment:
the result is aligns with spark. some different is return type not null.
which is not print in spark.
```
spark-sql (default)> select array_append(array(), 1);
[1]
spark-sql (default)> select typeof(array_append(array(), 1));
array<int>
spark-sql (default)> select array_append(array(), null);
[null]
spark-sql (default)> select typeof(array_append(array(), null));
array<void>
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]