I defined a small table in PostgreSQL as follows:
When I run a query with a STRING_AGG function where an ORDER BY clause is specified, the strings are not concatenated in the expected order. For example, these three queries:
return all the same result "b , a , c".
It seems that the ORDER BY clause is not pushed down to PostgreSQL, in fact all the three rewritten queries executed in PostgreSQL look like:
If the STRING_AGG function is not pushed down (e.g. in MySQL), I get an expected result.