feat(bindings): tprecision / tsample scalar functions#63
Closed
estebanzimanyi wants to merge 1 commit into
Closed
Conversation
Wraps MEOS temporal_tprecision and temporal_tsample as DuckDB scalar functions (single Temporal in, single Temporal out — these are NOT table functions despite the row-amplifying connotation of "sample"). Coverage: tprecision(tbool / tint / tfloat / ttext, INTERVAL, TIMESTAMP_TZ) -> same tsample (tbool / tint / tfloat / ttext, INTERVAL, TIMESTAMP_TZ) -> same tsample (..., VARCHAR interp) -> same For tsample's optional interpolation argument we accept any VARCHAR that MEOS interptype_from_string parses (linear / step / discrete); the 3-arg form defaults to linear. Date / timestamptz origin is converted from DuckDB's 1970 epoch to MEOS's 2000 epoch via the existing time_util.hpp helper. The INTERVAL duration is converted via IntervaltToInterval.
Member
Author
|
Superseded by #78. The newer PR ships the same tprecision/tsample surface plus a parity test (test/sql/parity/022_temporal_tprecision_tsample.test) and targets |
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
Wraps MEOS `temporal_tprecision` and `temporal_tsample` as DuckDB scalar functions. Despite the "sample" naming, these produce a single Temporal output per Temporal input — they are not table functions.
```sql
SELECT tprecision(tfloat '[1@2000-01-01, 5@2000-01-05]',
INTERVAL '1 day',
TIMESTAMPTZ '2000-01-01');
-- [1.02@1999-12-31, 1.54@2000-01-01, 3.54@2000-01-03, 4.52@2000-01-04]
SELECT tsample(tfloat '[1@2000-01-01, 5@2000-01-05]',
INTERVAL '1 day',
TIMESTAMPTZ '2000-01-01');
-- [1.04@2000-01-01, 4.04@2000-01-04]
```
Coverage
Registered for `tbool`, `tint`, `tfloat`, `ttext` (every temporal base type).
For `tsample`'s optional interpolation argument we accept any VARCHAR that MEOS `interptype_from_string` parses (`linear` / `step` / `discrete`); the 3-arg form defaults to `linear`.
Date / timestamptz origin is converted from DuckDB's 1970 epoch to MEOS's 2000 epoch via the existing `time_util.hpp` helper. The `INTERVAL` duration is converted via `IntervaltToInterval`.
Stacked on
Test plan