You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by ch...@apache.org on 2022/05/17 02:07:04 UTC
[calcite] branch main updated: [CALCITE-5137] EnumerableUncollect throws NPE if input has ((List) null)
This is an automated email from the ASF dual-hosted git repository.
chunwei pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new 664e24921c [CALCITE-5137] EnumerableUncollect throws NPE if input has ((List) null)
664e24921c is described below
commit 664e24921c521b9b8df03e4744d878a69dfeb10e
Author: dssysolyatin <dm...@gmail.com>
AuthorDate: Sat May 7 22:20:09 2022 +0300
[CALCITE-5137] EnumerableUncollect throws NPE if input has ((List) null)
---
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java | 2 +-
.../apache/calcite/test/enumerable/EnumerableUncollectTest.java | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
index 17eeb00fe1..636b27bfd8 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
@@ -117,7 +117,7 @@ public class SqlFunctions {
private static final Pattern FROM_BASE64_REGEXP = Pattern.compile("[\\t\\n\\r\\s]");
private static final Function1<List<Object>, Enumerable<Object>> LIST_AS_ENUMERABLE =
- Linq4j::asEnumerable;
+ a0 -> a0 == null ? Linq4j.emptyEnumerable() : Linq4j.asEnumerable(a0);
@SuppressWarnings("unused")
private static final Function1<Object[], Enumerable<@Nullable Object[]>> ARRAY_CARTESIAN_PRODUCT =
diff --git a/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableUncollectTest.java b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableUncollectTest.java
index 78f6ebfa6e..0721fae277 100644
--- a/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableUncollectTest.java
+++ b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableUncollectTest.java
@@ -34,6 +34,13 @@ class EnumerableUncollectTest {
"y=4");
}
+ @Test void simpleUnnestNullArray() {
+ final String sql = "SELECT * FROM UNNEST(CAST(null AS INTEGER ARRAY))";
+ tester()
+ .query(sql)
+ .returnsCount(0);
+ }
+
@Test void simpleUnnestArrayOfArrays() {
final String sql = "select * from UNNEST(array[array[3], array[4]]) as T2(y)";
tester()