Re: FDW RTE join pushdown fails to create plan with aggregates - Mailing list pgsql-hackers

From Kirill Reshke
Subject Re: FDW RTE join pushdown fails to create plan with aggregates
Date
Msg-id CALdSSPiXyFU=F42hG5CodkEdAsBezscRNT5iiJQ+h8_Oo8_MrQ@mail.gmail.com
Whole thread
In response to Re: FDW RTE join pushdown fails to create plan with aggregates  (Alexander Pyhalov <a.pyhalov@postgrespro.ru>)
Responses Re: FDW RTE join pushdown fails to create plan with aggregates
List pgsql-hackers
On Fri, 25 Sept 2026 at 12:20, Alexander Pyhalov
<a.pyhalov@postgrespro.ru> wrote:
>
>
> Hi.
>
> Yes, there's an issue, but it seems to be not specific to function
> pushdown.
> For example, the following test case
>
> EXPLAIN (VERBOSE, COSTS OFF)
> SELECT count(1) FROM remote_tbl r1, remote_tbl r2 GROUP BY r1.a;
> ERROR:  Aggref found where not expected

Hmm, very interesting, before report I checked on 0ee83dd4a99 and for
me it differs:

reshke=# explain
SELECT count(1) FROM rmt.a a, rmt.a b GROUP BY a.id
;
                                   QUERY PLAN
--------------------------------------------------------------------------------
 Finalize GroupAggregate  (cost=200.00..13594.87 rows=200 width=12)
   Group Key: a.id
   ->  Nested Loop  (cost=200.00..10179.87 rows=682600 width=12)
         ->  Partial GroupAggregate  (cost=100.00..777.98 rows=200 width=12)
               Group Key: a.id
               ->  Foreign Scan on a  (cost=100.00..761.35 rows=2925 width=4)
         ->  Materialize  (cost=100.00..877.93 rows=3413 width=0)
               ->  Foreign Scan on a b  (cost=100.00..860.86 rows=3413 width=0)
(8 rows)

reshke=# explain
SELECT count(1) FROM rmt.a, generate_series(1,1) GROUP BY id
;
ERROR:  Aggref found in non-Agg plan node


With 0ee83dd4a99~1 (e13851080c) both queries run OK

> I'm not sure, does issue affect only joinrels? Can't we encounter other
grouped rels while building foreign paths?

I didn't manage to get any exposure other than join-grouped rels.

-- 
Best regards,
Kirill Reshke



pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: RI fastpath misses checking EXECUTE on functions
Next
From: torikoshia
Date:
Subject: Re: RFC: Allow EXPLAIN to Output Page Fault Information