This is an automated email from the ASF dual-hosted git repository.
zabetak 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 96c1b1f171 [CALCITE-7281] Deprecate NullPolicy.ANY in favor of
NullPolicy.SEMI_STRICT
96c1b1f171 is described below
commit 96c1b1f17113d064892488930274b5033ddd1101
Author: Stamatis Zampetakis <[email protected]>
AuthorDate: Fri Nov 7 16:10:35 2025 +0100
[CALCITE-7281] Deprecate NullPolicy.ANY in favor of NullPolicy.SEMI_STRICT
---
.../calcite/adapter/enumerable/NullPolicy.java | 4 ++-
.../calcite/adapter/enumerable/RexImpTable.java | 35 +++++++++++-----------
.../sql/advise/SqlAdvisorGetHintsFunction.java | 2 +-
.../sql/advise/SqlAdvisorGetHintsFunction2.java | 2 +-
4 files changed, 22 insertions(+), 21 deletions(-)
diff --git
a/core/src/main/java/org/apache/calcite/adapter/enumerable/NullPolicy.java
b/core/src/main/java/org/apache/calcite/adapter/enumerable/NullPolicy.java
index 1d426ea43b..4000f97620 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/NullPolicy.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/NullPolicy.java
@@ -32,7 +32,9 @@ public enum NullPolicy {
STRICT,
/** Returns null if one of the arguments is null, and possibly other times.
*/
SEMI_STRICT,
- /** If any of the arguments are null, return null. */
+ /** If any of the arguments are null, return null.
+ * @deprecated {@link #SEMI_STRICT} has identical semantics so use this
instead. */
+ @Deprecated
ANY,
/** If the first argument is null, return null. */
ARG0,
diff --git
a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
index 521cc9f7e4..ca8f93feb9 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
@@ -716,8 +716,8 @@ void populate1() {
defineMethod(SHA512, BuiltInMethod.SHA512.method, NullPolicy.STRICT);
defineMethod(SUBSTRING, BuiltInMethod.SUBSTRING.method,
NullPolicy.STRICT);
defineMethod(FORMAT_NUMBER, BuiltInMethod.FORMAT_NUMBER.method,
NullPolicy.STRICT);
- defineMethod(LEFT, BuiltInMethod.LEFT.method, NullPolicy.ANY);
- defineMethod(RIGHT, BuiltInMethod.RIGHT.method, NullPolicy.ANY);
+ defineMethod(LEFT, BuiltInMethod.LEFT.method, NullPolicy.SEMI_STRICT);
+ defineMethod(RIGHT, BuiltInMethod.RIGHT.method, NullPolicy.SEMI_STRICT);
defineMethod(LPAD, BuiltInMethod.LPAD.method, NullPolicy.STRICT);
defineMethod(RPAD, BuiltInMethod.RPAD.method, NullPolicy.STRICT);
defineMethod(STARTS_WITH, BuiltInMethod.STARTS_WITH.method,
NullPolicy.STRICT);
@@ -803,7 +803,7 @@ void populate1() {
defineReflective(REGEXP_INSTR, BuiltInMethod.REGEXP_INSTR2.method,
BuiltInMethod.REGEXP_INSTR3.method,
BuiltInMethod.REGEXP_INSTR4.method,
BuiltInMethod.REGEXP_INSTR5.method);
- defineMethod(FIND_IN_SET, BuiltInMethod.FIND_IN_SET.method,
NullPolicy.ANY);
+ defineMethod(FIND_IN_SET, BuiltInMethod.FIND_IN_SET.method,
NullPolicy.SEMI_STRICT);
define(TRIM, new TrimImplementor());
@@ -1073,23 +1073,23 @@ void populate2() {
NullPolicy.STRICT);
defineMethod(SLICE, BuiltInMethod.SLICE.method, NullPolicy.STRICT);
defineMethod(ELEMENT, BuiltInMethod.ELEMENT.method, NullPolicy.STRICT);
- defineMethod(STRUCT_ACCESS, BuiltInMethod.STRUCT_ACCESS.method,
NullPolicy.ANY);
+ defineMethod(STRUCT_ACCESS, BuiltInMethod.STRUCT_ACCESS.method,
NullPolicy.SEMI_STRICT);
defineMethod(MEMBER_OF, BuiltInMethod.MEMBER_OF.method, NullPolicy.NONE);
defineMethod(ARRAY_APPEND, BuiltInMethod.ARRAY_APPEND.method,
NullPolicy.ARG0);
defineMethod(ARRAY_COMPACT, BuiltInMethod.ARRAY_COMPACT.method,
NullPolicy.STRICT);
- defineMethod(ARRAY_CONTAINS, BuiltInMethod.LIST_CONTAINS.method,
NullPolicy.ANY);
+ defineMethod(ARRAY_CONTAINS, BuiltInMethod.LIST_CONTAINS.method,
NullPolicy.SEMI_STRICT);
defineMethod(ARRAY_DISTINCT, BuiltInMethod.ARRAY_DISTINCT.method,
NullPolicy.STRICT);
- defineMethod(ARRAY_EXCEPT, BuiltInMethod.ARRAY_EXCEPT.method,
NullPolicy.ANY);
+ defineMethod(ARRAY_EXCEPT, BuiltInMethod.ARRAY_EXCEPT.method,
NullPolicy.SEMI_STRICT);
defineMethod(ARRAY_JOIN, BuiltInMethod.ARRAY_TO_STRING.method,
NullPolicy.STRICT);
defineMethod(ARRAY_INSERT, BuiltInMethod.ARRAY_INSERT.method,
NullPolicy.ARG0);
- defineMethod(ARRAY_INTERSECT, BuiltInMethod.ARRAY_INTERSECT.method,
NullPolicy.ANY);
+ defineMethod(ARRAY_INTERSECT, BuiltInMethod.ARRAY_INTERSECT.method,
NullPolicy.SEMI_STRICT);
defineMethod(ARRAY_LENGTH, BuiltInMethod.COLLECTION_SIZE.method,
NullPolicy.STRICT);
defineMethod(ARRAY_MAX, BuiltInMethod.ARRAY_MAX.method,
NullPolicy.STRICT);
defineMethod(ARRAY_MIN, BuiltInMethod.ARRAY_MIN.method,
NullPolicy.STRICT);
defineMethod(ARRAY_PREPEND, BuiltInMethod.ARRAY_PREPEND.method,
NullPolicy.ARG0);
- defineMethod(ARRAY_POSITION, BuiltInMethod.ARRAY_POSITION.method,
NullPolicy.ANY);
- defineMethod(ARRAY_REMOVE, BuiltInMethod.ARRAY_REMOVE.method,
NullPolicy.ANY);
+ defineMethod(ARRAY_POSITION, BuiltInMethod.ARRAY_POSITION.method,
NullPolicy.SEMI_STRICT);
+ defineMethod(ARRAY_REMOVE, BuiltInMethod.ARRAY_REMOVE.method,
NullPolicy.SEMI_STRICT);
defineMethod(ARRAY_REPEAT, BuiltInMethod.ARRAY_REPEAT.method,
NullPolicy.NONE);
defineMethod(ARRAY_REVERSE, BuiltInMethod.ARRAY_REVERSE.method,
NullPolicy.STRICT);
defineMethod(ARRAY_SIZE, BuiltInMethod.COLLECTION_SIZE.method,
NullPolicy.STRICT);
@@ -1097,16 +1097,16 @@ void populate2() {
defineMethod(ARRAY_TO_STRING, BuiltInMethod.ARRAY_TO_STRING.method,
NullPolicy.STRICT);
defineMethod(STRING_TO_ARRAY, BuiltInMethod.STRING_TO_ARRAY.method,
NullPolicy.ARG0);
- defineMethod(ARRAY_UNION, BuiltInMethod.ARRAY_UNION.method,
NullPolicy.ANY);
- defineMethod(ARRAYS_OVERLAP, BuiltInMethod.ARRAYS_OVERLAP.method,
NullPolicy.ANY);
- defineMethod(ARRAYS_ZIP, BuiltInMethod.ARRAYS_ZIP.method,
NullPolicy.ANY);
- defineMethod(EXISTS, BuiltInMethod.EXISTS.method, NullPolicy.ANY);
- defineMethod(MAP_CONCAT, BuiltInMethod.MAP_CONCAT.method,
NullPolicy.ANY);
- defineMethod(MAP_CONTAINS_KEY, BuiltInMethod.MAP_CONTAINS_KEY.method,
NullPolicy.ANY);
+ defineMethod(ARRAY_UNION, BuiltInMethod.ARRAY_UNION.method,
NullPolicy.SEMI_STRICT);
+ defineMethod(ARRAYS_OVERLAP, BuiltInMethod.ARRAYS_OVERLAP.method,
NullPolicy.SEMI_STRICT);
+ defineMethod(ARRAYS_ZIP, BuiltInMethod.ARRAYS_ZIP.method,
NullPolicy.SEMI_STRICT);
+ defineMethod(EXISTS, BuiltInMethod.EXISTS.method,
NullPolicy.SEMI_STRICT);
+ defineMethod(MAP_CONCAT, BuiltInMethod.MAP_CONCAT.method,
NullPolicy.SEMI_STRICT);
+ defineMethod(MAP_CONTAINS_KEY, BuiltInMethod.MAP_CONTAINS_KEY.method,
NullPolicy.SEMI_STRICT);
defineMethod(MAP_ENTRIES, BuiltInMethod.MAP_ENTRIES.method,
NullPolicy.STRICT);
defineMethod(MAP_KEYS, BuiltInMethod.MAP_KEYS.method, NullPolicy.STRICT);
defineMethod(MAP_VALUES, BuiltInMethod.MAP_VALUES.method,
NullPolicy.STRICT);
- defineMethod(MAP_FROM_ARRAYS, BuiltInMethod.MAP_FROM_ARRAYS.method,
NullPolicy.ANY);
+ defineMethod(MAP_FROM_ARRAYS, BuiltInMethod.MAP_FROM_ARRAYS.method,
NullPolicy.SEMI_STRICT);
defineMethod(MAP_FROM_ENTRIES, BuiltInMethod.MAP_FROM_ENTRIES.method,
NullPolicy.STRICT);
define(STR_TO_MAP, new StringToMapImplementor());
defineMethod(SUBSTRING_INDEX, BuiltInMethod.SUBSTRING_INDEX.method,
NullPolicy.STRICT);
@@ -4391,7 +4391,6 @@ private static List<Expression> harmonize(final
List<Expression> argValueList,
private List<Expression> unboxIfNecessary(final List<Expression>
argValueList) {
switch (nullPolicy) {
case STRICT:
- case ANY:
case SEMI_STRICT:
return Util.transform(argValueList,
AbstractRexCallImplementor::unboxExpression);
@@ -4943,7 +4942,7 @@ private static class QuantifyCollectionImplementor
extends AbstractRexCallImplem
QuantifyCollectionImplementor(SqlBinaryOperator binaryOperator,
RexCallImplementor binaryImplementor) {
- super("quantify", NullPolicy.ANY, false);
+ super("quantify", NullPolicy.SEMI_STRICT, false);
this.binaryOperator = binaryOperator;
this.binaryImplementor = binaryImplementor;
}
diff --git
a/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction.java
b/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction.java
index d49478ad6b..d1b05764e8 100644
---
a/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction.java
+++
b/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction.java
@@ -65,7 +65,7 @@ public class SqlAdvisorGetHintsFunction
(translator, call, operands) ->
Expressions.call(GET_COMPLETION_HINTS,
Iterables.concat(Collections.singleton(ADVISOR), operands)),
- NullPolicy.ANY, false);
+ NullPolicy.SEMI_STRICT, false);
private static final List<FunctionParameter> PARAMETERS =
ReflectiveFunctionBase.builder()
diff --git
a/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction2.java
b/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction2.java
index 1f5fe1a360..0ec33fda81 100644
---
a/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction2.java
+++
b/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction2.java
@@ -67,7 +67,7 @@ public class SqlAdvisorGetHintsFunction2
(translator, call, operands) ->
Expressions.call(GET_COMPLETION_HINTS,
Iterables.concat(Collections.singleton(ADVISOR), operands)),
- NullPolicy.ANY, false);
+ NullPolicy.SEMI_STRICT, false);
private static final List<FunctionParameter> PARAMETERS =
ReflectiveFunctionBase.builder()