While working on #10319 I tried introducing deterministic ordering into my input tables, by adding order_by with an 'index' column.
I have noticed that concat aggregate breaks if the table was ordered before.
Repro (e.g. in REPL):
c = Database.connect (Postgres ...) # put your Postgres connection details here
t = (Table.new [["X", [1,2,3]], ["Y", ['a', 'b', 'c']]]).select_into_database_table c "foobar" temporary=True
t.order_by "X" . print
r_unsorted = t.aggregate [Aggregate_Column.Concatenate "Y"]
r_unsorted.print
r_sorted = t.order_by "X" . aggregate [Aggregate_Column.Concatenate "Y"]
IO.println r_sorted
IO.println r_sorted.print
Expected behaviour
Both sorted and unsorted version should work and return a new table. The unsorted version may have an unspecified ordering in the concatenated string.
Actual behaviour
The line IO.println r_sorted.print currently prints:
(Error: There was an SQL error: ERROR: column "foobar.X" must appear in the GROUP BY clause or be used in an aggregate function
Pozycja: 214. [Query was: SELECT "foobar"."Concatenate Y" AS "Concatenate Y" FROM (SELECT (?) || string_agg(CASE WHEN "foobar"."Y" IS NULL THEN '' ELSE ("foobar"."Y") END, ?) || (?) AS "Concatenate Y" FROM "foobar" AS "foobar" ORDER BY "foobar"."X" ASC NULLS FIRST) AS "foobar" LIMIT 11])
While working on #10319 I tried introducing deterministic ordering into my input tables, by adding
order_by
with an 'index' column.I have noticed that concat
aggregate
breaks if the table was ordered before.Repro (e.g. in REPL):
Expected behaviour
Both sorted and unsorted version should work and return a new table. The unsorted version may have an unspecified ordering in the concatenated string.
Actual behaviour
The line
IO.println r_sorted.print
currently prints: