feat(bindings): bins(span | spanset, vsize, vorigin) table function#62
Closed
estebanzimanyi wants to merge 1 commit into
Closed
feat(bindings): bins(span | spanset, vsize, vorigin) table function#62estebanzimanyi wants to merge 1 commit into
estebanzimanyi wants to merge 1 commit into
Conversation
Adds the first MobilityDuck TableFunction registration: bins() that partitions a span (or spanset) into uniformly-sized bins anchored at a given origin and emits one row per bin. 10 overloads — every span / spanset base type: bins(intspan, INTEGER, INTEGER) -> TABLE(bin intspan) bins(bigintspan, BIGINT, BIGINT) -> TABLE(bin bigintspan) bins(floatspan, DOUBLE, DOUBLE) -> TABLE(bin floatspan) bins(datespan, INTERVAL, DATE) -> TABLE(bin datespan) bins(tstzspan, INTERVAL, TIMESTAMP_TZ) -> TABLE(bin tstzspan) bins(<spanset>, ... ) -> TABLE(bin <span>) Each overload gets its own templated bind via BinsKind dispatch. BinsBindData captures the three constant arguments at bind time and BinsInitGlobal materialises the MEOS bin array on first row of execution. BinsExecute emits up to STANDARD_VECTOR_SIZE rows per chunk. The destructor on BinsGlobalState frees the MEOS-allocated array. 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). Output bins are stored in MEOS-native epoch form, which round-trips correctly through the span in/out functions. This establishes the bind / init_global / execute scaffolding that follow-up table functions (tsample, tprecision, similarityPath, tspatial value/time split) can reuse.
This was referenced Apr 30, 2026
Member
Author
|
Superseded by the consolidated PR branch |
4 tasks
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 the first MobilityDuck TableFunction registration: `bins()` that partitions a span (or spanset) into uniformly-sized bins anchored at a given origin and emits one row per bin.
```sql
SELECT bin FROM bins(intspan '[1, 10)', 2, 0);
-- [0, 2)
-- [2, 4)
-- [4, 6)
-- [6, 8)
-- [8, 10)
SELECT bin FROM bins(tstzspan '[2000-01-01, 2000-01-04)',
INTERVAL '1 day',
TIMESTAMPTZ '2000-01-01');
-- [2000-01-01, 2000-01-02)
-- [2000-01-02, 2000-01-03)
-- [2000-01-03, 2000-01-04)
```
Coverage
10 overloads — every span / spanset base type:
Each overload returns a one-column relation `(bin )` matching the input's base type.
Implementation
Date and timestamptz inputs are converted from DuckDB's 1970 epoch to MEOS's 2000 epoch via the existing `time_util.hpp` helpers. Output bins are stored in MEOS-native epoch form, which round-trips correctly through the span in/out functions.
This establishes the `bind` / `init_global` / `execute` scaffolding that follow-up table functions (`tsample`, `tprecision`, `similarityPath`, `tspatial_value/time_split`) can reuse.
Test plan