RishavTiwari25 opened a new issue, #26243:
URL: https://github.com/apache/datafusion/issues/26243

   ### Describe the bug
   
   `array_concat` / `array_cat` fails to plan when one of the arguments is a 
plain `NULL` literal, and the error message names the element type of the 
*other* argument:
   
   ```sql
   > SELECT array_concat([1, 2], NULL);
   Error during planning: array_concat does not support type Int64
   
   > SELECT array_cat(NULL, [1, 2]);
   Error during planning: array_concat does not support type Int64
   ```
   
   The same calls work when the `NULL` is typed (`NULL::int[]`) or when a 
`NULL` appears inside a list, so this is only the untyped literal:
   
   ```sql
   > SELECT array_concat([1, 2], NULL::int[]);
   [1, 2]
   
   > SELECT array_concat([1, 2], [NULL]);
   [1, 2, NULL]
   ```
   
   `ArrayConcat::return_type` accepts `DataType::Null` arguments, but 
`ArrayConcat::coerce_types` runs every argument through 
`coerced_type_with_base_type_only`, whose fallback arm replaces a non-list type 
with the base type. The `Null` argument therefore becomes `Int64`, and the 
second `return_type` call rejects it.
   
   ### To Reproduce
   
   In `datafusion-cli`:
   
   ```sql
   SELECT array_concat([1, 2], NULL);
   SELECT array_cat(NULL, [1, 2]);
   SELECT array_concat(['a'], NULL);
   ```
   
   ### Expected behavior
   
   The untyped `NULL` is treated like a `NULL` list of the result type and the 
other arguments are returned, matching PostgreSQL (`array_cat(ARRAY[1, 2], 
NULL)` is `{1,2}`) and the typed-`NULL` behavior above:
   
   ```sql
   > SELECT array_concat([1, 2], NULL);
   [1, 2]
   ```
   
   ### Additional context
   
   Reproduced on `main` at 6663e4348 (debug build of `datafusion-cli`).
   
   #16349 covered `NULL::int[]` arguments; this is the remaining untyped case. 
I would like to work on this.


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