looks good to me.
I didn't find any issue.
group_by_has_partkey can even cope with:
EXPLAIN (COSTS OFF, settings)
SELECT c collate "C" collate case_insensitive collate "C", count(c)
FROM pagg_tab3 GROUP BY c collate "C" collate case_insensitive collate
"C" ORDER BY 1;
so i guess in group_by_has_partkey
if (IsA(groupexpr, RelabelType))
groupexpr = ((RelabelType *) groupexpr)->arg;
should be enough.
not need while loop.
while (IsA(groupexpr, RelabelType))
groupexpr = (Expr *) (castNode(RelabelType, groupexpr))->arg;