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

   ## Which issue does this PR close?
   
   - Closes #21841.
   
   ## Rationale for this change
   
   `make_array_inner` handled arguments that are all `NULL`-typed by summing 
their lengths and wrapping the nulls in a single-row list. That is right for 
literals, whose arrays have one row, but a `Null`-typed column has one row per 
input row, so `SELECT make_array(n) FROM (VALUES (NULL), (NULL), (NULL)) AS 
t(n)` failed with an internal error ("returned a different number of rows than 
expected. Expected: 3, Got: 1"). `[n, n]`, `array_append(n, n)` and 
`map([n::varchar], [n])` reach the same code.
   
   Picks up where #21842 (closed as stale) left off, with the logic kept inside 
`make_array_inner` so the `array_append` and `map` callers are covered too.
   
   ## What changes are included in this PR?
   
   A `null_list_array` helper builds a `List(Null)` array with one row per 
input row, each holding one null per argument (a single row with an empty list 
when there are no arguments, as before). The Spark `array` function had its own 
copy of the old logic and now uses the helper.
   
   ## Are these changes tested?
   
   Yes. `make_array.slt` covers `make_array(n)`, `[n, n]` (with its type), 
`unnest([n, n])` and `array_append(n, n)` over a NULL-typed column; 
`spark/array/array.slt` covers the Spark `array` function. The existing literal 
cases (`make_array(NULL)`, `make_array(NULL, NULL, NULL)`, `make_array()`) are 
unchanged.
   
   ## Are there any user-facing changes?
   
   `make_array` (and the functions built on it) over a `Null`-typed column 
returns one list per row instead of an internal error.
   


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