Skip to content

string_agg does not respect ORDER BY on 49.0.0 #17011

@nuno-faria

Description

@nuno-faria

Describe the bug

The string_agg function does not respect the ORDER BY clause in the 49.0.0 release. It does work after e1a5cdf I believe (#16625).

I discovered this while attempting to upgrade datafusion-python to datafusion 49.0.0, which causes some tests to fail. Would it be possible to release a minor update to allow datafusion-python to support datafusion 49?

To Reproduce

On the released 49.0.0 version:

> create table t (k varchar, v int);
0 row(s) fetched.
Elapsed 0.055 seconds.

> insert into t values ('a', 2), ('b', 3), ('c', 1);
+-------+
| count |
+-------+
| 3     |
+-------+
1 row(s) fetched.
Elapsed 0.065 seconds.

> select string_agg(k, ',' order by v) from t;
+---------------------------------------------------------+
| string_agg(t.k,Utf8(",")) ORDER BY [t.v ASC NULLS LAST] |
+---------------------------------------------------------+
| a,b,c                                                   |
+---------------------------------------------------------+
1 row(s) fetched.

Expected behavior

Should return:

+---------------------------------------------------------+
| string_agg(t.k,Utf8(",")) ORDER BY [t.v ASC NULLS LAST] |
+---------------------------------------------------------+
| c,a,b                                                   |
+---------------------------------------------------------+

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    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