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


##########
be/src/exprs/function/cast/cast_to_array.h:
##########
@@ -42,11 +41,8 @@ WrapperType create_array_wrapper(FunctionContext* context, 
const DataTypePtr& fr
 
     DataTypePtr from_nested_type = from_type->get_nested_type();
 
-    /// In query SELECT CAST([] AS Array(Array(String))) from type is 
Array(Nothing)
-    bool from_empty_array = from_nested_type->get_primitive_type() == 
INVALID_TYPE;
-
     if (from_type->get_number_of_dimensions() != 
to_type.get_number_of_dimensions() &&
-        !from_empty_array) {
+        !from_nested_type->is_null_literal()) {

Review Comment:
   This still leaves a BE/FE divergence for deeper null-only arrays. For 
example, with constant folding disabled, `CAST([[NULL]] AS 
ARRAY<ARRAY<ARRAY<INT>>>)` reaches this guard with a 2-D source and 3-D target, 
but `from_nested_type` is `Array(Nullable(NULL-literal))`, so 
`is_null_literal()` is false and BE returns the same-dimensional-array error 
before the nested cast can turn the inner nulls into typed nested arrays.
   
   FE literal casting handles the same shape recursively: 
`ArrayLiteral.uncheckedCastTo()` casts each item to the target item type, and 
`NullLiteral` becomes typed, so the folded path can succeed while the BE path 
fails. The exception needs to recognize null-only array subtrees recursively, 
or defer this dimensionality check far enough for the nested null-literal cast 
to handle them, and the regression should include a nested case such as 
`[[NULL]] -> ARRAY<ARRAY<ARRAY<INT>>>`.
   



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