Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-6348] ARRAY_OVERLAP with a NULL argument crashes the compiler #3746

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,8 @@ private static RelDataType arrayInsertReturnType(SqlOperatorBinding opBinding) {
ReturnTypes.BOOLEAN_NULLABLE.andThen(SqlTypeTransforms.COLLECTION_ELEMENT_TYPE_NULLABLE),
OperandTypes.and(
OperandTypes.SAME_SAME,
OperandTypes.family(SqlTypeFamily.ARRAY, SqlTypeFamily.ARRAY)));
OperandTypes.family(SqlTypeFamily.ARRAY, SqlTypeFamily.ARRAY),
OperandTypes.NONNULL_NONNULL));

private static RelDataType deriveTypeArraysZip(SqlOperatorBinding opBinding) {
final List<RelDataType> argComponentTypes = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ public abstract class SqlTypeTransforms {
(opBinding, typeToTransform) -> {
final List<RelDataType> argComponentTypes = new ArrayList<>();
for (RelDataType arrayType : opBinding.collectOperandTypes()) {
final RelDataType componentType = requireNonNull(arrayType.getComponentType());
final RelDataType componentType = arrayType.getComponentType();
if (componentType == null) {
// NULL supplied for array
return arrayType;
}
argComponentTypes.add(componentType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7122,10 +7122,13 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) {
f.checkType("arrays_overlap(array[1, 2], cast(null as integer array))", "BOOLEAN");
f.checkNull("arrays_overlap(array[1], array[2, null])");
f.checkType("arrays_overlap(array[2, null], array[1])", "BOOLEAN");
f.checkFails("^arrays_overlap(array[1, 2], true)^",
"Cannot apply 'ARRAYS_OVERLAP' to arguments of type 'ARRAYS_OVERLAP\\("
+ "<INTEGER ARRAY>, <BOOLEAN>\\)'. Supported form\\(s\\): 'ARRAYS_OVERLAP\\("
+ "<EQUIVALENT_TYPE>, <EQUIVALENT_TYPE>\\)'", false);
final String expected = "Cannot apply 'ARRAYS_OVERLAP' to arguments of type 'ARRAYS_OVERLAP\\("
+ "<.*>, <.*>\\)'. Supported form\\(s\\): 'ARRAYS_OVERLAP\\("
+ "<EQUIVALENT_TYPE>, <EQUIVALENT_TYPE>\\)'";
f.checkFails("^arrays_overlap(array[1, 2], true)^", expected, false);
f.checkFails("^arrays_overlap(null, null)^", expected, false);
f.checkFails("^arrays_overlap(null, array[1])^", expected, false);
f.checkFails("^arrays_overlap(array[1], null)^", expected, false);
}

/** Tests {@code ARRAYS_ZIP} function from Spark. */
Expand Down
Loading