PG18: Fix multi-shard MIN/MAX on composite types by blessing record aggregates #8429
+220
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DESCRIPTION: Fix multi-shard MIN/MAX on composite types by blessing record aggregates
fixes #8400
PG18 adds
MIN/MAXsupport for composite values.postgres/postgres@a0f1fce
On Citus distributed tables, multi-shard execution computes
MIN/MAXper shard on workers and then re-aggregates those shard results on the coordinator. The shard results arrive asrecordwithout a concrete record typmod/tuple descriptor, so the coordinator cannot parse/compare them and fails with:ERROR: input of anonymous composite types is not implementedSolution
Extend
BlessRecordExpression()to handleAggrefnodes that returnRECORDOID. Formin/maxover a composite column, derive the tuple descriptor from the aggregate’s input argument rowtype, convert it to arecordtupledesc, and callBlessTupleDesc()so Postgres assigns a non-anonymous record typmod. This preserves enough metadata across the worker→coordinator boundary for the coordinator-stage aggregate to work.Tests
Add a PG18 regression case that creates a distributed table with a composite type and verifies distributed
MIN/MAXreturns the expected composite values instead of raising the anonymous composite error.