morrySnow opened a new pull request, #67822:
URL: https://github.com/apache/doris/pull/67822

   ## Problem
   
   Invalid inputs to `array_flatten`, `array_compact`, `array_union`, and 
`array_intersect` could expose implementation details instead of returning a 
stable analysis error. Depending on the function, users could see a frontend 
`ClassCastException`, a backend "Unexpected columns" error and stack trace, or 
a Debug backend assertion that terminated the process.
   
   ## Reproduction
   
   ```sql
   SELECT array_flatten(1);
   SELECT array_compact(1);
   SELECT array_union(ARRAY(to_bitmap(1)), ARRAY(to_bitmap(1)));
   SELECT array_intersect(ARRAY(to_bitmap(1)), ARRAY(to_bitmap(1)));
   ```
   
   ## Root cause
   
   `array_flatten` accepted a scalar as a zero-level nested array while 
deriving its custom signature, and `array_compact` cast its input to 
`ArrayType` before checking the outer type. The set-style functions rejected 
only a subset of complex element types, even though the backend implementation 
supports a smaller set of physical columns. Backend execution then relied on 
unchecked casts and fatal assertions under the assumption that the frontend had 
validated every plan.
   
   ## Fix
   
   - Validate array shape before frontend casts and signature derivation.
   - Define a positive frontend allowlist matching the backend columns 
supported by hash-based array set operations.
   - Reject unsupported element types such as `BITMAP` during analysis.
   - Replace user-reachable backend assertions with checked `InvalidArgument` 
errors, preserving the original status category when execution fails.
   - Guard empty nested arrays while flattening offsets.
   
   ## Tests
   
   - Full frontend build with checkstyle.
   - Debug backend build, header-hygiene checks, final link, and glibc 
compatibility check.
   - New regression coverage for the four invalid inputs plus normal and 
empty-array behavior.
   


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