github-actions[bot] commented on code in PR #65267:
URL: https://github.com/apache/doris/pull/65267#discussion_r3528232527


##########
regression-test/suites/query_p0/sql_functions/array_functions/test_array_nested_type_check.groovy:
##########
@@ -0,0 +1,51 @@
+// 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("test_array_nested_type_check") {
+    sql "set enable_nereids_planner = true"
+    sql "set enable_fallback_to_original_planner = false"
+
+    test {
+        sql "explain verbose select array_union([], [[1]])"
+        exception "array_union does not support types: ARRAY<ARRAY<TINYINT>>"
+    }
+
+    test {
+        sql "select array_union([], [[1]])"
+        exception "array_union does not support types: ARRAY<ARRAY<TINYINT>>"
+    }
+
+    test {
+        sql "select arrays_overlap([], [[1]])"
+        exception "arrays_overlap does not support types: 
ARRAY<ARRAY<TINYINT>>"
+    }
+
+    test {
+        sql "select array_position([], [1])"
+        exception "array_position does not support complex types"
+    }
+
+    test {
+        sql "select array_remove([], [1])"
+        exception "array_remove does not support types: ARRAY<ARRAY<TINYINT>>"
+    }
+
+    test {
+        sql "select countequal([], [1])"

Review Comment:
   This still leaves the same bare-empty-array path open in a few parallel 
functions. `array_contains([], [1])`, `array_contains_all([], [[1]])`, and 
`array_except([], [[1]])` can still take the nested-array type from the 
non-first argument during signature computation because those FE functions have 
the same indexed `AnyDataType`/`FollowToAnyDataType` patterns but no 
`checkLegalityBeforeTypeCoercion()` guard. They then reach BE paths that only 
handle simple element columns: `array_contains` uses `FunctionArrayIndex`, 
`array_contains_all` dispatches through `dispatch_switch_all`, and 
`array_except` uses `ALL_COLUMNS_SIMPLE`, none of which handles `TYPE_ARRAY` 
elements. Please include these parallel functions in the fix and cover them in 
this new legality test.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ArrayPosition.java:
##########
@@ -81,6 +81,9 @@ public void checkLegalityBeforeTypeCoercion() {
         if (argType.isArrayType() && ((ArrayType) 
argType).getItemType().isComplexType()) {
             throw new AnalysisException("array_position does not support 
complex types: " + toSql());
         }
+        if (getArgument(1).getDataType().isComplexType()) {

Review Comment:
   This new right-argument check still misses JSONB and VARIANT. In Nereids, 
`JsonType` and `VariantType` are `PrimitiveType`s, so `isComplexType()` is 
false for them. With an empty first argument, `array_position([], 
jsonb_parse('1'))` can still infer the array item type from the second argument 
and pass analysis, then hit the shared BE `FunctionArrayIndex` dispatch, which 
does not handle JSONB/VARIANT element types and fails at execution. Please 
reject `isVariantType()` and `isJsonType()` here as the `array_remove` and 
`countequal` checks do.



-- 
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]

Reply via email to