Re: Wrong results with grouping sets
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: Alena Rybakina <lena.ribackina@yandex.ru>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2023-11-17T03:25:11Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Remove the RTE_GROUP RTE if we drop the groupClause
- ffe12d1d22e7 18.0 landed
-
Mark expressions nullable by grouping sets
- f5050f795aea 18.0 landed
-
Introduce an RTE for the grouping step
- 247dea89f761 18.0 landed
On Thu, Nov 16, 2023 at 11:25 PM Alena Rybakina <lena.ribackina@yandex.ru> wrote: > I noticed that this query worked correctly in the main branch with the > inequality operator: > > postgres=# select distinct on (a, b) a, b from (values (3, 1), (2, 2)) as > t (a, b) where a > b group by grouping sets((a, b), (a)); a | b ---+--- 3 | > 1 3 | (2 rows) > > So, I think you are right) > Thanks for taking an interest in this patch and verifying it. > I looked at your patch and noticed a few things: > > 1. I think you should add a test with the cube operator, because I noticed > that the order of the query in the result has also changed: > Hmm, I'm not sure if that's necessary. The wrong result order you saw here is caused by the same reason explained above: the planner fails to realize that Var 'a' and 'b' are nullable by the grouping sets, making them no longer always equal to each other. This issue should have been covered in the tests added by v1 patch. Thanks Richard