-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
Describe the bug
The first_value and last_value aggregate functions do not preserve Field metadata from their input arguments. When a column has metadata attached to it, using first_value() or last_value() on that column results in the metadata being lost in the output.
This also affects DISTINCT ON queries since they use first_value internally.
To Reproduce
-- Assuming a table with a column that has metadata attached
SELECT first_value(id)
FROM table_with_metadata;
-- The metadata is lost (returns NULL instead of the expected metadata value)Expected behavior
The first_value and last_value functions should preserve the Field metadata from their input argument, similar to how other operations preserve metadata.
Additional context
The fix requires implementing the return_field() method for both FirstValue and LastValue aggregate UDFs to copy the metadata from the input field to the output field.
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 [email protected]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels