apache / apache/datafusion

`array_sort` doesnt respect array inputs for sort order/nulls first

Open
#24,132 1 comment 0 reactions 1 assignee Claimed by @JSOD11 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

https://github.com/apache/datafusion/blob/f27e50c13647efa5292d5ef5b1e4ed6af3015962/datafusion/functions-nested/src/sort.rs#L163-L177

If we pass in an array for the 2nd/3rd args, the code only takes the first value of the array.

### To Reproduce

```sql
DataFusion CLI v54.1.0
> select array_sort(a, b) from values ([2,1,3], 'desc'), ([2,1,3], 'asc') t(a,b);
+---------------------+
| array_sort(t.a,t.b) |
+---------------------+
| [3, 2, 1] |
| [3, 2, 1] |
+---------------------+
2 row(s) fetched.
Elapsed 0.073 seconds.
```

### Expected behavior

Either they should respect the values per row, or should explicitly fail with error that it expects a constant/scalar input for those options

### Additional context

_No response_

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.