Skip to content

feat(bindings): tprecision / tsample — temporal time-domain rebinning#78

Closed
estebanzimanyi wants to merge 1 commit into
mainfrom
feat/parity-temporal-022-accessors
Closed

feat(bindings): tprecision / tsample — temporal time-domain rebinning#78
estebanzimanyi wants to merge 1 commit into
mainfrom
feat/parity-temporal-022-accessors

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Closes the user-facing tprecision/tsample gap in `temporal/022_temporal`.

New SQL surface

Signature Routed through
`tprecision(tint, interval)` `temporal_tprecision` (default origin = MEOS `2000-01-03`)
`tprecision(tint, interval, timestamptz)` same
`tprecision(tfloat, ...)` × 2 same
`tsample(tbool, interval)` `temporal_tsample` (default origin, default `discrete` interp)
`tsample(tbool, interval, timestamptz)` same
`tsample(tbool, interval, timestamptz, varchar)` same
`tsample(tint tfloat

16 new registrations total: 4 `tprecision` overloads + 12 `tsample` overloads.

Implementation

Both handlers walk the rows manually (rather than using `BinaryExecutor`) since they have variable arity (2-4 args). The interpolation string is parsed in C++ via `ParseInterpString`:

  • `"none"` / `""` → `INTERP_NONE`
  • `"discrete"` → `DISCRETE`
  • `"step"` → `STEP`
  • `"linear"` → `LINEAR`

Unknown values throw `InvalidInputException`.

`DEFAULT_T_ORIGIN` is `0` (MEOS encodes its `2000-01-03` reference origin as 0 microseconds), matching MobilityDB's SQL `DEFAULT '2000-01-03'`.

Tests

  • `test/sql/parity/022_temporal_tprecision_tsample.test` — 7 assertions including default-origin and explicit-origin variants, linear/step/discrete interpolation, and a `statement error` case for an invalid interp string.
  • Full suite: 759 assertions / 14 test cases passing under `TZ=UTC`.

Coverage delta

Per the audit in PR #66:

  • `temporal/022_temporal`: tprecision (2/2) + tsample (4/4) names now covered.

Test plan

  • `cmake --build . --target shell unittest` clean
  • New parity test passes (7/7)
  • Full suite green (759/14)

Closes the user-facing tprecision/tsample gap in temporal/022_temporal.

New SQL surface:

- tprecision(tint|tfloat, interval[, origin timestamptz])
  -> Temporal_tprecision -> tnumber
  4 overloads (2 base types × 2 origin variants).

- tsample(tbool|tint|tfloat|ttext, interval[, origin timestamptz[, interp text]])
  -> Temporal_tsample -> Temporal of same type
  12 overloads (4 base types × 3 origin/interp variants).

The interpolation string is parsed in C++ via ParseInterpString
("none" | "discrete" | "step" | "linear"), throwing on unknown values.
DEFAULT_T_ORIGIN matches MEOS's `2000-01-03` reference origin (encoded
as 0 microseconds in MEOS's epoch).

Test: test/sql/parity/022_temporal_tprecision_tsample.test (7 assertions
including default-origin and explicit-origin variants, linear/step/discrete
interpolation, and an error case for an invalid interp string).
Full suite: 759 / 14 cases under TZ=UTC.

Files also gain a trailing newline at EOF.
@estebanzimanyi

Copy link
Copy Markdown
Member Author

Superseded by the consolidated PR branch consolidate/temporal-ops-parity. All changes from this PR are included in that branch as a single squashed commit. Please review and merge the consolidated branch instead.

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