apache / apache/datafusion

concat_ws on array arguments silently stringifies the arrays

Open
#21,703 1 comment 0 reactions 1 assignee Claimed by @hcrosse View on GitHub
bug
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Describe the bug

`concat_ws(sep, array, array, ...)` dispatches to the string `concat_ws` UDF, which coerces the array arguments to their string representation and joins them textually. For example:

```sql
select concat_ws(',', make_array(1, 2, 3), make_array(4, 5));
```

returns `[1, 2, 3],[4, 5]` instead of either rejecting the call as a type error or producing well-defined array semantics.

This is the same class of bug as #18020. Filing separately because the right fix is less obvious as `concat_ws` doesn't have a direct array equivalent the way `concat` maps to `array_concat`, so "reject with a plan error" may be the better answer here.

### To Reproduce

```sql
select concat_ws(',', make_array(1, 2, 3), make_array(4, 5));
-- returns: [1, 2, 3],[4, 5]
```

### Expected behavior

Either a plan error rejecting array arguments, or well-defined array semantics, not silent stringification.

### Additional context

Noticed by @neilconway while reviewing #21689.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.