You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "snuyanzin (via GitHub)" <gi...@apache.org> on 2024/03/05 11:53:46 UTC

Re: [PR] [CALCITE-6283] Function ARRAY_APPEND with a NULL array argument crashes with NullPointerException [calcite]

snuyanzin commented on code in PR #3706:
URL: https://github.com/apache/calcite/pull/3706#discussion_r1512696170


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -6277,6 +6277,19 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) {
     f.checkScalar("rand_integer(2, 11)", 1, "INTEGER NOT NULL");
   }
 
+  /** Test case for <a href="https://issues.apache.org/jira/browse/CALCITE-6283">
+   * [CALCITE-6283] Function array_append with a NULL array argument crashes with
+   * NullPointerException</a>. */
+  @Test void testArrayNullFunc() {
+    final String expected = "Illegal use of 'NULL'";
+    final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.SPARK);
+    f.checkFails("^array_append(null, 2)^", expected, false);
+    f.checkFails("^array_prepend(null, 2)^", expected, false);
+    f.checkFails("^array_remove(null, 2)^", expected, false);
+    f.checkFails("^array_contains(null, 2)^", expected, false);
+    f.checkFails("^array_position(null, 2)^", expected, false);

Review Comment:
   It seems there is a similar issue for `array_min/array_max` should we fix it within this issue or create a separate one?



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org