Skip to content

feat(bindings): tagg_min(ttext) / tagg_max(ttext) overloads#54

Closed
estebanzimanyi wants to merge 1 commit into
feat/aggregate-fn-spanunionfrom
feat/aggregate-fn-ttext
Closed

feat(bindings): tagg_min(ttext) / tagg_max(ttext) overloads#54
estebanzimanyi wants to merge 1 commit into
feat/aggregate-fn-spanunionfrom
feat/aggregate-fn-ttext

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Summary

Adds the ttext branch of the temporal min/max aggregates that PR #52 explicitly skipped ("ttext skipped — text merge needs text_cmp plumbing"). MEOS exports `text_cmp` as a public API, so the wrapper datum-merge functions are 2-liners:

```cpp
static Datum mduck_datum_min_text(Datum l, Datum r) {
return text_cmp((text*)l, (text*)r) < 0 ? l : r;
}
```

Each merge fn casts both Datums to `text*` (PG varlena), invokes `text_cmp`, and returns whichever Datum the comparison selects.

Coverage

Aggregate Inputs Output
`tagg_min(ttext)` ttext ttext — per-instant minimum (lexicographic)
`tagg_max(ttext)` ttext ttext — per-instant maximum (lexicographic)

```sql
SELECT tagg_min(t) FROM (VALUES (ttext '"hello"@2000-01-01'), (ttext '"alpha"@2000-01-01')) tt(t);
-- {"alpha"@2000-01-01 00:00:00+00}

SELECT tagg_max(t) FROM (VALUES (ttext '"hello"@2000-01-01'), (ttext '"zebra"@2000-01-01')) tt(t);
-- {"zebra"@2000-01-01 00:00:00+00}
```

Stacked on

Test plan

  • tagg_min(ttext) / tagg_max(ttext) produce correct lexicographic results
  • Existing int/float overloads still work (regression check)

Adds the ttext branch of the temporal min/max aggregates that the prior
PR explicitly skipped (ttext merge needs text_cmp plumbing). MEOS
exports text_cmp as a public API, so the wrapper datum_min_text /
datum_max_text equivalents are simple two-line functions.

Each merge fn casts both Datums to text* (PG varlena) and invokes
text_cmp; the result selects which Datum to return. tagg_min picks
the smaller, tagg_max the larger.
@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