You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
max() drops field metadata / extension type from its result (first_value keeps it) #26916
max() (and likely min()) drops field metadata, including Arrow extension types, from its result. first_value() keeps it, so aggregates are inconsistent.
Found while reviewing #21714. Reproduces on main with any metadata-carrying column (e.g. table_with_metadata in metadata.slt), so it predates that PR.
CREATETABLEu (id UUID);
INSERT INTO u VALUES (X'00010203040506070809000102030506');
SELECT arrow_metadata(max(id), 'ARROW:extension:name') FROM u; -- NULLSELECT arrow_metadata(first_value(id), 'ARROW:extension:name') FROM u; -- arrow.uuid
On main, in metadata.slt:
SELECT arrow_metadata(max(id), 'metadata_key') FROM table_with_metadata; -- NULLSELECT arrow_metadata(first_value(id), 'metadata_key') FROM table_with_metadata; -- the id field
Expected behavior
max / min return a value of the same type as their input, so the result field should keep the input's metadata (as first_value does).
For comparison, DuckDB: typeof(max(uuid_col)) is UUID and typeof(max(json_col)) is JSON.
Additional context
Related: #21981 (MinAccumulator dropping inner-field metadata for lists).
Activity
rishiiicreates commentedon Oct 30, 2026
i can take this, will add return_field to Max and Min to preserve input field metadata and add tests in metadata.slt
cblp commentedon Oct 30, 2026
take
adriangb commentedon Nov 2, 2026
I looked at #26938 and #26939, both opened around the same time. I'd reviewed #26938 but after looking at #26939 I think #26939 looks better. @rishiiicreates could we close #26938 and focus review effort on #26939?
fix: keep field metadata in the result of min and max (apache#26939)