Skip to content

feat(bindings): tprecision / tsample scalar functions#63

Closed
estebanzimanyi wants to merge 1 commit into
feat/table-fn-binsfrom
feat/table-fn-tsample-tprecision
Closed

feat(bindings): tprecision / tsample scalar functions#63
estebanzimanyi wants to merge 1 commit into
feat/table-fn-binsfrom
feat/table-fn-tsample-tprecision

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

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

Function Inputs Output
`tprecision` `(temporal, INTERVAL, TIMESTAMP_TZ)` same temporal type
`tsample` `(temporal, INTERVAL, TIMESTAMP_TZ)` same temporal type
`tsample` `(temporal, INTERVAL, TIMESTAMP_TZ, VARCHAR interp)` same temporal type

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

  • tprecision and tsample both produce expected resampled outputs
  • All four temporal base types compile and link

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.
@estebanzimanyi

Copy link
Copy Markdown
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 main directly instead of stacking on feat/table-fn-bins. 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