Skip to content

Commit 96c1b1f

Browse files
committed
[CALCITE-7281] Deprecate NullPolicy.ANY in favor of NullPolicy.SEMI_STRICT
1 parent 0f148c7 commit 96c1b1f

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

core/src/main/java/org/apache/calcite/adapter/enumerable/NullPolicy.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public enum NullPolicy {
3232
STRICT,
3333
/** Returns null if one of the arguments is null, and possibly other times. */
3434
SEMI_STRICT,
35-
/** If any of the arguments are null, return null. */
35+
/** If any of the arguments are null, return null.
36+
* @deprecated {@link #SEMI_STRICT} has identical semantics so use this instead. */
37+
@Deprecated
3638
ANY,
3739
/** If the first argument is null, return null. */
3840
ARG0,

core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ void populate1() {
716716
defineMethod(SHA512, BuiltInMethod.SHA512.method, NullPolicy.STRICT);
717717
defineMethod(SUBSTRING, BuiltInMethod.SUBSTRING.method, NullPolicy.STRICT);
718718
defineMethod(FORMAT_NUMBER, BuiltInMethod.FORMAT_NUMBER.method, NullPolicy.STRICT);
719-
defineMethod(LEFT, BuiltInMethod.LEFT.method, NullPolicy.ANY);
720-
defineMethod(RIGHT, BuiltInMethod.RIGHT.method, NullPolicy.ANY);
719+
defineMethod(LEFT, BuiltInMethod.LEFT.method, NullPolicy.SEMI_STRICT);
720+
defineMethod(RIGHT, BuiltInMethod.RIGHT.method, NullPolicy.SEMI_STRICT);
721721
defineMethod(LPAD, BuiltInMethod.LPAD.method, NullPolicy.STRICT);
722722
defineMethod(RPAD, BuiltInMethod.RPAD.method, NullPolicy.STRICT);
723723
defineMethod(STARTS_WITH, BuiltInMethod.STARTS_WITH.method, NullPolicy.STRICT);
@@ -803,7 +803,7 @@ void populate1() {
803803
defineReflective(REGEXP_INSTR, BuiltInMethod.REGEXP_INSTR2.method,
804804
BuiltInMethod.REGEXP_INSTR3.method, BuiltInMethod.REGEXP_INSTR4.method,
805805
BuiltInMethod.REGEXP_INSTR5.method);
806-
defineMethod(FIND_IN_SET, BuiltInMethod.FIND_IN_SET.method, NullPolicy.ANY);
806+
defineMethod(FIND_IN_SET, BuiltInMethod.FIND_IN_SET.method, NullPolicy.SEMI_STRICT);
807807

808808
define(TRIM, new TrimImplementor());
809809

@@ -1073,40 +1073,40 @@ void populate2() {
10731073
NullPolicy.STRICT);
10741074
defineMethod(SLICE, BuiltInMethod.SLICE.method, NullPolicy.STRICT);
10751075
defineMethod(ELEMENT, BuiltInMethod.ELEMENT.method, NullPolicy.STRICT);
1076-
defineMethod(STRUCT_ACCESS, BuiltInMethod.STRUCT_ACCESS.method, NullPolicy.ANY);
1076+
defineMethod(STRUCT_ACCESS, BuiltInMethod.STRUCT_ACCESS.method, NullPolicy.SEMI_STRICT);
10771077
defineMethod(MEMBER_OF, BuiltInMethod.MEMBER_OF.method, NullPolicy.NONE);
10781078
defineMethod(ARRAY_APPEND, BuiltInMethod.ARRAY_APPEND.method, NullPolicy.ARG0);
10791079
defineMethod(ARRAY_COMPACT, BuiltInMethod.ARRAY_COMPACT.method, NullPolicy.STRICT);
1080-
defineMethod(ARRAY_CONTAINS, BuiltInMethod.LIST_CONTAINS.method, NullPolicy.ANY);
1080+
defineMethod(ARRAY_CONTAINS, BuiltInMethod.LIST_CONTAINS.method, NullPolicy.SEMI_STRICT);
10811081
defineMethod(ARRAY_DISTINCT, BuiltInMethod.ARRAY_DISTINCT.method, NullPolicy.STRICT);
1082-
defineMethod(ARRAY_EXCEPT, BuiltInMethod.ARRAY_EXCEPT.method, NullPolicy.ANY);
1082+
defineMethod(ARRAY_EXCEPT, BuiltInMethod.ARRAY_EXCEPT.method, NullPolicy.SEMI_STRICT);
10831083
defineMethod(ARRAY_JOIN, BuiltInMethod.ARRAY_TO_STRING.method,
10841084
NullPolicy.STRICT);
10851085
defineMethod(ARRAY_INSERT, BuiltInMethod.ARRAY_INSERT.method, NullPolicy.ARG0);
1086-
defineMethod(ARRAY_INTERSECT, BuiltInMethod.ARRAY_INTERSECT.method, NullPolicy.ANY);
1086+
defineMethod(ARRAY_INTERSECT, BuiltInMethod.ARRAY_INTERSECT.method, NullPolicy.SEMI_STRICT);
10871087
defineMethod(ARRAY_LENGTH, BuiltInMethod.COLLECTION_SIZE.method, NullPolicy.STRICT);
10881088
defineMethod(ARRAY_MAX, BuiltInMethod.ARRAY_MAX.method, NullPolicy.STRICT);
10891089
defineMethod(ARRAY_MIN, BuiltInMethod.ARRAY_MIN.method, NullPolicy.STRICT);
10901090
defineMethod(ARRAY_PREPEND, BuiltInMethod.ARRAY_PREPEND.method, NullPolicy.ARG0);
1091-
defineMethod(ARRAY_POSITION, BuiltInMethod.ARRAY_POSITION.method, NullPolicy.ANY);
1092-
defineMethod(ARRAY_REMOVE, BuiltInMethod.ARRAY_REMOVE.method, NullPolicy.ANY);
1091+
defineMethod(ARRAY_POSITION, BuiltInMethod.ARRAY_POSITION.method, NullPolicy.SEMI_STRICT);
1092+
defineMethod(ARRAY_REMOVE, BuiltInMethod.ARRAY_REMOVE.method, NullPolicy.SEMI_STRICT);
10931093
defineMethod(ARRAY_REPEAT, BuiltInMethod.ARRAY_REPEAT.method, NullPolicy.NONE);
10941094
defineMethod(ARRAY_REVERSE, BuiltInMethod.ARRAY_REVERSE.method, NullPolicy.STRICT);
10951095
defineMethod(ARRAY_SIZE, BuiltInMethod.COLLECTION_SIZE.method, NullPolicy.STRICT);
10961096
defineMethod(ARRAY_SLICE, BuiltInMethod.ARRAY_SLICE.method, NullPolicy.STRICT);
10971097
defineMethod(ARRAY_TO_STRING, BuiltInMethod.ARRAY_TO_STRING.method,
10981098
NullPolicy.STRICT);
10991099
defineMethod(STRING_TO_ARRAY, BuiltInMethod.STRING_TO_ARRAY.method, NullPolicy.ARG0);
1100-
defineMethod(ARRAY_UNION, BuiltInMethod.ARRAY_UNION.method, NullPolicy.ANY);
1101-
defineMethod(ARRAYS_OVERLAP, BuiltInMethod.ARRAYS_OVERLAP.method, NullPolicy.ANY);
1102-
defineMethod(ARRAYS_ZIP, BuiltInMethod.ARRAYS_ZIP.method, NullPolicy.ANY);
1103-
defineMethod(EXISTS, BuiltInMethod.EXISTS.method, NullPolicy.ANY);
1104-
defineMethod(MAP_CONCAT, BuiltInMethod.MAP_CONCAT.method, NullPolicy.ANY);
1105-
defineMethod(MAP_CONTAINS_KEY, BuiltInMethod.MAP_CONTAINS_KEY.method, NullPolicy.ANY);
1100+
defineMethod(ARRAY_UNION, BuiltInMethod.ARRAY_UNION.method, NullPolicy.SEMI_STRICT);
1101+
defineMethod(ARRAYS_OVERLAP, BuiltInMethod.ARRAYS_OVERLAP.method, NullPolicy.SEMI_STRICT);
1102+
defineMethod(ARRAYS_ZIP, BuiltInMethod.ARRAYS_ZIP.method, NullPolicy.SEMI_STRICT);
1103+
defineMethod(EXISTS, BuiltInMethod.EXISTS.method, NullPolicy.SEMI_STRICT);
1104+
defineMethod(MAP_CONCAT, BuiltInMethod.MAP_CONCAT.method, NullPolicy.SEMI_STRICT);
1105+
defineMethod(MAP_CONTAINS_KEY, BuiltInMethod.MAP_CONTAINS_KEY.method, NullPolicy.SEMI_STRICT);
11061106
defineMethod(MAP_ENTRIES, BuiltInMethod.MAP_ENTRIES.method, NullPolicy.STRICT);
11071107
defineMethod(MAP_KEYS, BuiltInMethod.MAP_KEYS.method, NullPolicy.STRICT);
11081108
defineMethod(MAP_VALUES, BuiltInMethod.MAP_VALUES.method, NullPolicy.STRICT);
1109-
defineMethod(MAP_FROM_ARRAYS, BuiltInMethod.MAP_FROM_ARRAYS.method, NullPolicy.ANY);
1109+
defineMethod(MAP_FROM_ARRAYS, BuiltInMethod.MAP_FROM_ARRAYS.method, NullPolicy.SEMI_STRICT);
11101110
defineMethod(MAP_FROM_ENTRIES, BuiltInMethod.MAP_FROM_ENTRIES.method, NullPolicy.STRICT);
11111111
define(STR_TO_MAP, new StringToMapImplementor());
11121112
defineMethod(SUBSTRING_INDEX, BuiltInMethod.SUBSTRING_INDEX.method, NullPolicy.STRICT);
@@ -4391,7 +4391,6 @@ private static List<Expression> harmonize(final List<Expression> argValueList,
43914391
private List<Expression> unboxIfNecessary(final List<Expression> argValueList) {
43924392
switch (nullPolicy) {
43934393
case STRICT:
4394-
case ANY:
43954394
case SEMI_STRICT:
43964395
return Util.transform(argValueList,
43974396
AbstractRexCallImplementor::unboxExpression);
@@ -4943,7 +4942,7 @@ private static class QuantifyCollectionImplementor extends AbstractRexCallImplem
49434942

49444943
QuantifyCollectionImplementor(SqlBinaryOperator binaryOperator,
49454944
RexCallImplementor binaryImplementor) {
4946-
super("quantify", NullPolicy.ANY, false);
4945+
super("quantify", NullPolicy.SEMI_STRICT, false);
49474946
this.binaryOperator = binaryOperator;
49484947
this.binaryImplementor = binaryImplementor;
49494948
}

core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class SqlAdvisorGetHintsFunction
6565
(translator, call, operands) ->
6666
Expressions.call(GET_COMPLETION_HINTS,
6767
Iterables.concat(Collections.singleton(ADVISOR), operands)),
68-
NullPolicy.ANY, false);
68+
NullPolicy.SEMI_STRICT, false);
6969

7070
private static final List<FunctionParameter> PARAMETERS =
7171
ReflectiveFunctionBase.builder()

core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class SqlAdvisorGetHintsFunction2
6767
(translator, call, operands) ->
6868
Expressions.call(GET_COMPLETION_HINTS,
6969
Iterables.concat(Collections.singleton(ADVISOR), operands)),
70-
NullPolicy.ANY, false);
70+
NullPolicy.SEMI_STRICT, false);
7171

7272
private static final List<FunctionParameter> PARAMETERS =
7373
ReflectiveFunctionBase.builder()

0 commit comments

Comments
 (0)