Skip to content

feat(bindings): wmin / wmax / wsum window aggregates#56

Closed
estebanzimanyi wants to merge 1 commit into
feat/aggregate-fn-extent-scalarfrom
feat/aggregate-fn-window
Closed

feat(bindings): wmin / wmax / wsum window aggregates#56
estebanzimanyi wants to merge 1 commit into
feat/aggregate-fn-extent-scalarfrom
feat/aggregate-fn-window

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Summary

Adds 6 sliding-window aggregate overloads over tint and tfloat:

Aggregate Inputs Output
`wmin(tint, INTERVAL)` tint, INTERVAL tint — min over each `[t, t+interval]` window
`wmin(tfloat, INTERVAL)` tfloat, INTERVAL tfloat
`wmax(tint, INTERVAL)` / `wmax(tfloat, INTERVAL)` same same — max
`wsum(tint, INTERVAL)` / `wsum(tfloat, INTERVAL)` same same — sum

```sql
SELECT wmin(t, INTERVAL '1 day') FROM (VALUES (tint '5@2000-01-01'), (tint '3@2000-01-02')) tt(t);
-- {[5@2000-01-01, 3@2000-01-02, 3@2000-01-03]}
```

Implementation

`WindowAggFunction<TRANSFN, MERGE_FN, CROSSINGS>` is a binary aggregate over (Temporal blob, `interval_t`). The interval is converted to MEOS `Interval` via the existing `time_util.hpp::IntervaltToInterval` helper and forwarded to MEOS `tint_w*_transfn` / `tfloat_w*_transfn`. State, Combine, Finalize, and Destroy reuse the skiplist-backed pattern.

Out of scope

`wavg` is not registered: its MEOS combine path needs `datum_sum_double2` which is a MEOS-internal struct (sum, count) layout not available through the public API. Adding it requires either an upstream MEOS export or a local reimplementation that depends on internal struct layout.

Test plan

  • All 6 overloads produce correct values for representative inputs
  • No segfaults (destructor pattern from existing skiplist aggregates)

Adds sliding-window aggregates over tint and tfloat:

  wmin(tint,    INTERVAL) -> tint     min over each [t, t+interval] window
  wmin(tfloat,  INTERVAL) -> tfloat
  wmax(tint,    INTERVAL) -> tint
  wmax(tfloat,  INTERVAL) -> tfloat
  wsum(tint,    INTERVAL) -> tint
  wsum(tfloat,  INTERVAL) -> tfloat

Each input row contributes its temporal value plus the (constant)
window-width interval; the aggregate emits a single temporal value
whose values at each instant reflect the minimum / maximum / sum over
the window centred on that instant.

Implementation: WindowAggFunction<TRANSFN, MERGE_FN, CROSSINGS> binary
aggregate over (Temporal blob, interval_t). The interval is converted
to MEOS Interval via the existing time_util.hpp helper and forwarded
to MEOS tint_w*_transfn / tfloat_w*_transfn. State, Combine, Finalize,
and Destroy reuse the skiplist-backed pattern.

wavg deferred — needs datum_sum_double2 which is a MEOS-internal
struct (sum, count) not available through the public API.
@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