feat(bindings): scalar extent overloads (integer/bigint/float/date/timestamptz)#55
Closed
estebanzimanyi wants to merge 1 commit intofeat/aggregate-fn-ttextfrom
Closed
feat(bindings): scalar extent overloads (integer/bigint/float/date/timestamptz)#55estebanzimanyi wants to merge 1 commit intofeat/aggregate-fn-ttextfrom
estebanzimanyi wants to merge 1 commit intofeat/aggregate-fn-ttextfrom
Conversation
…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.
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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`:
```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