Commit Graph

2 Commits (324e1b47b03572004b4a448ec037f9cc865f340a)

Author SHA1 Message Date
onderkalaci 324e1b47b0 Pg now has its own any_value, don't create aggregate if exists
Relevant PG commit:
2ddab010c2
2ddab010c2777c6a965cea82dc1b809ddc33ecc1
2023-07-28 15:48:49 +03:00
Jelte Fennema 9fb897a074
Fix queries with repartition joins and group by unique column (#3157)
Postgres doesn't require you to add all columns that are in the target list to
the GROUP BY when you group by a unique column (or columns). It even actively
removes these group by clauses when you do.

This is normally fine, but for repartition joins it is not. The reason for this
is that the temporary tables don't have these primary key columns. So when the
worker executes the query it will complain that it is missing columns in the
group by.

This PR fixes that by adding an ANY_VALUE aggregate around each variable in
the target list that does is not contained in the group by or in an aggregate.
This is done only for repartition joins.

The ANY_VALUE aggregate chooses the value from an undefined row in the
group.
2019-11-08 15:36:18 +01:00