morrySnow commented on code in PR #67822:
URL: https://github.com/apache/doris/pull/67822#discussion_r4011817688
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ArrayUnion.java:
##########
@@ -68,11 +69,18 @@ public ArrayUnion withChildren(List<Expression> children) {
@Override
public void checkLegalityBeforeTypeCoercion() {
- DataType argType = getArgument(0).getDataType();
- if (argType.isArrayType() && (((ArrayType)
argType).getItemType().isComplexType()
- || ((ArrayType) argType).getItemType().isVariantType()
- || ((ArrayType) argType).getItemType().isJsonType())) {
- throw new AnalysisException("array_union does not support types: "
+ argType.toSql());
+ for (Expression child : getArguments()) {
+ DataType argType = child.getDataType();
+ if (argType == NullType.INSTANCE) {
+ continue;
+ }
+ if (!argType.isArrayType()) {
+ throw new AnalysisException("array_union requires ARRAY
arguments, but got " + argType.toSql());
+ }
+ DataType itemType = ((ArrayType) argType).getItemType();
+ if (!itemType.canBeUsedInArraySetOperation()) {
Review Comment:
Fixed in aebba23a85b. ArrayUnion and ArrayExcept now keep the pre-coercion
check limited to ARRAY shape and validate backend physical support in
checkLegalityAfterRewrite(), after indexed AnyDataType has selected the common
element type. Mixed VARBINARY/STRING and TIME/STRING inputs therefore resolve
to ARRAY<STRING> and remain valid, while identical VARBINARY or TIME inputs are
still rejected for their unsupported resolved physical type. Added positive
mixed-type cases and retained the unsupported-type negatives; forced oracle
generation and the normal regression run both pass.
##########
regression-test/suites/nereids_function_p0/scalar_function/array_function_invalid_argument.groovy:
##########
@@ -0,0 +1,85 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("array_function_invalid_argument") {
+ test {
+ sql "select array_flatten(1)"
+ exception "array_flatten requires an ARRAY argument, but got TINYINT"
+ }
+
+ test {
+ sql "select array_compact(1)"
+ exception "array_compact requires an ARRAY argument, but got TINYINT"
+ }
+
+ test {
+ sql "select array_compact(array(to_bitmap(1), to_bitmap(1)))"
+ exception "array_compact does not support type BITMAP"
+ }
+
+ test {
+ sql "select array_compact(array(hll_hash('a'), hll_hash('a')))"
+ exception "array_compact does not support type HLL"
+ }
+
+ test {
+ sql "select array_compact(array(to_quantile_state(1, 2048),
to_quantile_state(1, 2048)))"
+ exception "array_compact does not support type QUANTILE_STATE"
+ }
+
+ test {
+ sql "select array_union(array(to_bitmap(1)), array(to_bitmap(1)))"
+ exception "array_union does not support element type BITMAP"
+ }
+
+ test {
+ sql "select array_union(array(cast('a' as varbinary)), array(cast('b'
as varbinary)))"
+ exception "array_union does not support element type VARBINARY"
+ }
+
+ test {
+ sql "select array_union(array(cast('12:34:56' as time(0))),
array(cast('12:34:57' as time(0))))"
+ exception "array_union does not support element type TIME"
+ }
+
+ test {
+ sql "select array_intersect(array(to_bitmap(1)), array(to_bitmap(1)))"
+ exception "array_intersect does not support element type BITMAP"
+ }
+
+ test {
+ sql "select array_intersect(array(cast('a' as varbinary)),
array(cast('b' as varbinary)))"
+ exception "array_intersect does not support element type VARBINARY"
+ }
+
+ test {
+ sql "select array_intersect(array(cast('12:34:56' as time(0))),
array(cast('12:34:57' as time(0))))"
+ exception "array_intersect does not support element type TIME"
+ }
+
+ test {
+ sql "select array_except(array(to_bitmap(1)), array(to_bitmap(1)))"
Review Comment:
Fixed in aebba23a85b. Added resolved-type physical-support checks for
array_distinct, single-argument array_enumerate_uniq, array_position,
array_contains, countequal, array_remove, and array_contains_all, and aligned
the parallel arrays_overlap and array_except_all paths as well. The shared
equality/hash support set includes TIME for the dispatch_switch_all/scalar
paths while excluding unsupported BITMAP and VARBINARY columns. Added
representative BITMAP/VARBINARY negatives plus TIME positives covering the
distinct, scalar-dispatch, and all-dispatch variants. The regression suite
passes with the generated oracle.
##########
regression-test/suites/nereids_function_p0/scalar_function/array_function_invalid_argument.groovy:
##########
@@ -0,0 +1,85 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("array_function_invalid_argument") {
+ test {
+ sql "select array_flatten(1)"
+ exception "array_flatten requires an ARRAY argument, but got TINYINT"
+ }
+
+ test {
+ sql "select array_compact(1)"
+ exception "array_compact requires an ARRAY argument, but got TINYINT"
+ }
+
+ test {
+ sql "select array_compact(array(to_bitmap(1), to_bitmap(1)))"
Review Comment:
Fixed in aebba23a85b. Added a recursive comparability predicate and applied
it to array_compact, array_sort, and array_reverse_sort, including nested
arrays; array_min/array_max now use their exact backend dispatch support set;
and array_sortby now validates comparator argument 1 rather than the payload
argument 0. Added BITMAP negatives for every comparator path, including nested
array_sort coverage and the argument-1 sortby case. FE full build/checkstyle
and the regression suite pass.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]