Skip to content

feat(bindings): scalar extent overloads (integer/bigint/float/date/timestamptz)#55

Closed
estebanzimanyi wants to merge 1 commit intofeat/aggregate-fn-ttextfrom
feat/aggregate-fn-extent-scalar
Closed

feat(bindings): scalar extent overloads (integer/bigint/float/date/timestamptz)#55
estebanzimanyi wants to merge 1 commit intofeat/aggregate-fn-ttextfrom
feat/aggregate-fn-extent-scalar

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

Summary

Adds 5 scalar overloads to the `extent()` `AggregateFunctionSet`, matching MobilityDB's `CREATE AGGREGATE extent(integer)` / `(bigint)` / `(float)` / `(date)` / `(timestamptz)` registrations from `015_span_aggfuncs.in.sql`:

Overload Returns
`extent(integer)` `intspan`
`extent(bigint)` `bigintspan`
`extent(float)` `floatspan` (DuckDB `DOUBLE`)
`extent(date)` `datespan`
`extent(timestamptz)` `tstzspan`

```sql
SELECT extent(v) FROM (VALUES (1), (5), (3)) tt(v);
-- [1, 6)

SELECT extent(v) FROM (VALUES (DATE '2000-01-01'), (DATE '2000-01-05')) tt(v);
-- [2000-01-01, 2000-01-06)
```

Implementation

Each subtype gets its own functor (`IntExtentFunction`, `BigintExtentFunction`, `FloatExtentFunction`, `DateExtentFunction`, `TimestamptzExtentFunction`) that bridges to the matching MEOS `*_extent_transfn` (`int_extent_transfn`, `bigint_extent_transfn`, etc.). All share the existing `SpanExtentState` and `SpanExtentBase` (Initialize / Combine / Finalize) from PR #47.

Epoch conversion: `date` and `timestamptz` inputs use DuckDB's 1970 epoch; MEOS uses PostgreSQL's 2000 epoch. The functors convert via the existing `time_util.hpp` helpers (`ToMeosDate` / `DuckDBToMeosTimestamp`). The output Span is stored in MEOS-native epoch form, which round-trips correctly through the existing span in/out functions.

Stacked on

Test plan

  • All 5 scalar input types produce correct extent
  • NULL handling (mid-run NULL ignored)
  • Date / timestamptz round-trip correctly across the epoch boundary
  • Existing span/spanset/set/tnumber overloads still work (regression)

…mestamptz)

Adds 5 scalar overloads to the extent() AggregateFunctionSet, matching
MobilityDB's CREATE AGGREGATE extent(integer) / (bigint) / (float) /
(date) / (timestamptz) registrations:

  extent(integer)     -> intspan
  extent(bigint)      -> bigintspan
  extent(float)       -> floatspan       (DOUBLE in DuckDB)
  extent(date)        -> datespan
  extent(timestamptz) -> tstzspan

Each subtype gets its own functor that bridges to the matching MEOS
*_extent_transfn (int_extent_transfn, bigint_extent_transfn, etc.).
Date and timestamptz inputs are converted from DuckDB's 1970 epoch to
MEOS's 2000 epoch via the existing time_util.hpp helpers
(ToMeosDate / DuckDBToMeosTimestamp). The output Span is stored in
MEOS-native epoch form, which round-trips correctly through the
existing span in/out functions.

Verified for distinct, NULL-handling (mid-run), and round-trip
correctness for date / tstz across the epoch boundary.
@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