Skip to content

array_concat fails with when passed NULL list literals #16349

Closed
@alexanderbianchi

Description

@alexanderbianchi

Describe the bug

The array_concat function throws an Arrow compute error concat requires input of at least one array when called with NULL list literals (e.g., NULL::integer[]). The function incorrectly attempts to pass empty arrays to Arrow's concat function instead of recognizing that NULL list literals should be handled as null inputs.

Note: Mixed cases work correctly (e.g., array_concat(NULL::integer[], [1,2,3]) returns [1,2,3]), so the issue is specifically when ALL arguments are NULL arrays.

To Reproduce

-- This query should return NULL but throws an error instead
SELECT array_concat(NULL::integer[]);

-- These variations also fail:
SELECT array_concat(NULL::integer[], NULL::integer[]);
SELECT array_concat(NULL::text[]);
SELECT array_concat(NULL::bigint[]);

Expected behavior

The function should handle NULL list literals gracefully and return NULL, similar to how other array functions handle NULL inputs:

-- Should return:
SELECT array_concat(NULL::integer[]);
-- Expected: NULL

SELECT array_concat(NULL::integer[], NULL::integer[]);
-- Expected: NULL

Additional context

DataFusion version: v48.0.0 (current main branch)
Rust version: 1.87.0

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions