RishavTiwari25 opened a new pull request, #26254:
URL: https://github.com/apache/datafusion/pull/26254

   ## Which issue does this PR close?
   
   - Closes #26243.
   
   ## Rationale for this change
   
   `array_concat([1, 2], NULL)` and `array_cat(NULL, [1, 2])` fail to plan with 
`array_concat does not support type Int64`, even though the typed form 
`array_concat([1, 2], NULL::int[])` works and PostgreSQL returns `{1,2}` for 
`array_cat(ARRAY[1, 2], NULL)`.
   
   `ArrayConcat::return_type` accepts `Null` arguments, but `coerce_types` ran 
every argument through `coerced_type_with_base_type_only`, whose fallback turns 
a non-list type into the base element type. The untyped `NULL` became `Int64`, 
and the second `return_type` call rejected it.
   
   ## What changes are included in this PR?
   
   `ArrayConcat::coerce_types` now coerces an untyped `NULL` argument to the 
result list type, so the planner casts it to a `NULL` list and 
`array_concat_inner` skips it like any other all-null argument. Other arguments 
are coerced as before.
   
   ## What is the testing strategy for this PR?
   
   New `sqllogictest` cases in `array/array_concat.slt` cover an untyped `NULL` 
in the first, middle and last position, a nested list, the result type, and 
`array_concat(NULL, NULL)`.
   
   ## Are there any user-facing changes?
   
   `array_concat` / `array_cat` accept an untyped `NULL` argument instead of 
failing to plan.
   
   I used an AI coding assistant while working on this change; I have read the 
diff and the tests and can walk through them.
   
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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