dssysolyatin commented on code in PR #2854:
URL: https://github.com/apache/calcite/pull/2854#discussion_r1128088425
##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -5451,7 +5461,11 @@ ImmutableList<RelNode> retrieveCursors() {
case CURSOR:
case IN:
case NOT_IN:
- subQuery = requireNonNull(getSubQuery(expr, null));
+ subQuery = getSubQuery(expr, null);
+ if (subQuery == null && (kind == SqlKind.SOME || kind == SqlKind.ALL))
{
+ break;
+ }
+ assert subQuery != null;
Review Comment:
Probably it can be removed. However, I feel that it's important to keep it
because requireNonNull is applied to `subQuery.expr`. If a NullPointerException
is thrown, it could be difficult to identify whether the root cause lies with
`subQuery` or `subQuery.expr`.
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -3636,6 +3636,44 @@ public static Object[] array(Object... args) {
return args;
}
+ /**
+ * Returns whether there is an element in {@code list} for which {@code
predicate} is true.
+ * Also, if {@code predicate} returns null for any element of {@code list}
+ * and there are no true comparison result is obtained, the result will be
null, not false.
+ */
+ public static @Nullable <E> Boolean nullableExists(List<? extends E> list,
+ Function1<E, Boolean> predicate) {
+ boolean nullExists = false;
+ for (E e : list) {
+ Boolean res = predicate.apply(e);
+ if (res == null) {
+ nullExists = true;
+ } else if (res) {
+ return true;
+ }
+ }
+ return nullExists ? null : false;
+ }
+
+ /**
+ * Returns whether {@code predicate} is true for all elements of {@code
list}.
+ * Also, if {@code predicate} returns null for any element of {@code list}
+ * and there are no false comparison result is obtained, the result will be
null, not true.
Review Comment:
Fixed.
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -3636,6 +3636,44 @@ public static Object[] array(Object... args) {
return args;
}
+ /**
+ * Returns whether there is an element in {@code list} for which {@code
predicate} is true.
+ * Also, if {@code predicate} returns null for any element of {@code list}
+ * and there are no true comparison result is obtained, the result will be
null, not false.
Review Comment:
Fixed.
--
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]