Skip to content

Conversation

@m3hm3t
Copy link
Contributor

@m3hm3t m3hm3t commented Dec 30, 2025

DESCRIPTION: Fix multi-shard MIN/MAX on composite types by blessing record aggregates

fixes #8400

PG18 adds MIN/MAX support for composite values.

postgres/postgres@a0f1fce

On Citus distributed tables, multi-shard execution computes MIN/MAX per shard on workers and then re-aggregates those shard results on the coordinator. The shard results arrive as record without a concrete record typmod/tuple descriptor, so the coordinator cannot parse/compare them and fails with:

ERROR: input of anonymous composite types is not implemented

Solution

Extend BlessRecordExpression() to handle Aggref nodes that return RECORDOID. For min/max over a composite column, derive the tuple descriptor from the aggregate’s input argument rowtype, convert it to a record tupledesc, and call BlessTupleDesc() 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/MAX returns the expected composite values instead of raising the anonymous composite error.

@m3hm3t m3hm3t self-assigned this Dec 30, 2025
@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.80%. Comparing base (8cec88d) to head (bb5c32d).

Additional details and impacted files
@@                     Coverage Diff                      @@
##           m3hm3t/pg18_minmax_array    #8429      +/-   ##
============================================================
- Coverage                     88.81%   88.80%   -0.01%     
============================================================
  Files                           287      287              
  Lines                         63255    63271      +16     
  Branches                       7932     7934       +2     
============================================================
+ Hits                          56179    56190      +11     
- Misses                         4745     4746       +1     
- Partials                       2331     2335       +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@m3hm3t m3hm3t changed the title M3hm3t/min max array 2 PG18: Fix multi-shard MIN/MAX on composite types by blessing record aggregates Dec 30, 2025
…ORD types in distributed tables

PG18: Add tests for MIN/MAX aggregate OID resolution on ANYARRAY and RECORD types
@m3hm3t m3hm3t force-pushed the m3hm3t/min_max_array_2 branch from 583b195 to 6a353d8 Compare December 31, 2025 08:11
@m3hm3t m3hm3t force-pushed the m3hm3t/min_max_array_2 branch from 6a353d8 to bb5c32d Compare December 31, 2025 08:13
@m3hm3t m3hm3t changed the base branch from main to m3hm3t/pg18_minmax_array December 31, 2025 08:13
@m3hm3t m3hm3t force-pushed the m3hm3t/pg18_minmax_array branch 2 times, most recently from 958b157 to 2719bad Compare January 5, 2026 08:34
@m3hm3t m3hm3t force-pushed the m3hm3t/pg18_minmax_array branch 2 times, most recently from caae21c to 42c04c6 Compare January 7, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow MIN()/MAX() aggregates on arrays and composite types

2 participants