Skip to content

feat(bindings): extend extent(*) to spanset and set surfaces#48

Closed
estebanzimanyi wants to merge 1 commit into
feat/aggregate-fn-extentfrom
feat/aggregate-fn-extent-spanset-set
Closed

feat(bindings): extend extent(*) to spanset and set surfaces#48
estebanzimanyi wants to merge 1 commit into
feat/aggregate-fn-extentfrom
feat/aggregate-fn-extent-spanset-set

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Summary

Adds 10 new aggregate overloads to the `extent()` set introduced in #47:

  • `extent() → ` for int/bigint/float/date/tstzspanset (5 overloads)
  • `extent() → ` for int/bigint/float/date/tstzset (5 overloads — `textset` has no span equivalent so it's skipped)

```sql
SELECT extent(s) FROM (VALUES (intspanset '{[1, 3), [5, 7)}'), (intspanset '{[10, 12)}')) t(s);
-- [1, 12)

SELECT extent(s) FROM (VALUES (intset '{1, 3, 5}'), (intset '{10, 20}')) t(s);
-- [1, 21)

SELECT extent(s) FROM (VALUES (datespanset '{[2000-01-01, 2000-01-03)}'), (datespanset '{[2000-01-05, 2000-01-10)}')) t(s);
-- [2000-01-01, 2000-01-10)
```

Implementation

Adds `SpansetExtentFunction` and `SetExtentFunction` functors. Both reuse the shared `SpanExtentState` (`Span span + bool isset`) and `SpanExtentBase` (Initialize / Combine / Finalize). Only `Operation` differs — it dispatches to the corresponding MEOS transfn:

  • `spanset_extent_transfn(state, ss)`
  • `set_extent_transfn(state, s)`

These return a palloc'd `Span*` on first call (when state is NULL); the wrapper memcpy-into-state-and-frees, then expands the inline state in place on subsequent calls — same convention as the original `SpanExtentFunction`.

Stacked on

Test plan

  • Smoke test all 3 surfaces (span / spanset / set) for all 5 base types
  • NULL handling: mixed NULL + value works for each surface
  • Existing test suite still passes locally

Adds 10 new aggregate overloads to the existing extent() set:

- extent(<spanset>) -> <span>  for int/bigint/float/date/tstzspanset
- extent(<set>)     -> <span>  for int/bigint/float/date/tstzset
                                (textset has no span equivalent)

Each new functor (SpansetExtentFunction, SetExtentFunction) reuses the
shared SpanExtentState (Span span + bool isset) and the shared
Initialize / Combine / Finalize via SpanExtentBase. Operation dispatches
to the corresponding MEOS transfn:

- spanset_extent_transfn(state, ss)
- set_extent_transfn(state, s)

These return a palloc'd Span* on first call (NULL state) which we
memcpy-into-state-and-free, then expand the inline state in place on
subsequent calls — same convention as the original SpanExtentFunction.
@estebanzimanyi

Copy link
Copy Markdown
Member Author

Consolidated into #60 (aggregate cluster squash). The full chain of aggregate work is now reviewable as a single PR; this branch's commits are preserved in #60's history. Closing to minimize the review queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant