Skip to content

feat(bindings): tgeompoint distance + temporal-position predicates batch#64

Closed
estebanzimanyi wants to merge 2 commits into
mainfrom
feat/parity-tgeompoint-distance-and-temporal-position
Closed

feat(bindings): tgeompoint distance + temporal-position predicates batch#64
estebanzimanyi wants to merge 2 commits into
mainfrom
feat/parity-tgeompoint-distance-and-temporal-position

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Salvaged from an interrupted parity-audit session. Adds a coherent slice of the MobilityDB SQL surface that MobilityDuck did not yet expose, plus a docs page cataloguing structural gaps that won't be closed.

New SQL surface

tgeompoint distance

  • `tdistance(tgeompoint, geometry)` and `(geometry, tgeompoint)` — both directions
  • `nearestApproachInstant` — 3 overloads on `tgeompoint × {geometry, tgeompoint}`
  • `nearestApproachDistance` / `nad` — 10 overloads on `tgeompoint × {geometry, stbox, tgeompoint}` both directions

stbox split functions

  • `stboxes(tgeompoint)`
  • `splitNStboxes(tgeompoint, INTEGER)`
  • `splitEachNStboxes(tgeompoint, INTEGER)`

Temporal-position predicates on (tstzspan, temporal) and (temporal, tstzspan)

  • `before`, `after`, `overbefore`, `overafter` registered as named functions. The MobilityDB operator forms (`<<#`, `#>>`, `&<#`, `#&>`) are unreachable through DuckDB's parser; the named-function surface is the equivalent and is documented in the new `docs/DuckDB-Parity-Gaps.md`.

Serialization on temporal

  • `as_wkb`, `as_hexwkb`.

Tnumber TableFunction surface (first table-returning surface in the temporal subsystem)

  • `valueSplit`, `similarityPath` — registration helpers split out as `TemporalTypes::RegisterTnumberValueSplit` / `RegisterSimilarityPath`.

setSRID / asMFJSON on tspatial

  • `Tspatial_set_srid`, `Tspatial_as_mfjson`.

Tests

  • `025_temporal_tile.test` (22 assertions)
  • `038_temporal_similarity.test` (15 assertions)
  • `064_tpoint_distance.test` (7 assertions)

Full suite: 796 assertions / 16 test cases passing under `TZ=UTC`.

Docs

`docs/DuckDB-Parity-Gaps.md` catalogues:

  • Multi-character operator tokens DuckDB's parser rejects (and the named-function equivalents);
  • `GEOMETRY` type-trip operators that depend on PostGIS-specific OIDs;
  • `setSRID` / `asMFJSON` SRS-resolution differences.

This is a structural inventory, not an open work list.

Test plan

  • `cmake --build . --target shell unittest` clean
  • Full suite green (796/16) under `TZ=UTC`
  • Each new parity test passes individually

New SQL surface added in this batch:

tgeompoint distance:
- tdistance(tgeompoint, geometry) and (geometry, tgeompoint) — both directions
- nearestApproachInstant — 3 overloads on tgeompoint × {geometry, tgeompoint}
- nearestApproachDistance / nad — 10 overloads on tgeompoint × {geometry,
  stbox, tgeompoint} both directions

stbox split functions on tgeompoint:
- stboxes(tgeompoint) -> LIST(stbox)
- splitNStboxes(tgeompoint, INTEGER) -> LIST(stbox)
- splitEachNStboxes(tgeompoint, INTEGER) -> LIST(stbox)

Temporal-position predicates on (tstzspan, temporal) and (temporal, tstzspan):
- before, after, overbefore, overafter — registered as named functions
  (DuckDB's parser does not accept `<<#` / `#>>` / `&<#` / `#&>`).

Serialization on temporal:
- as_wkb, as_hexwkb (binary serialization round-trip).

Tnumber tableFunction surface:
- valueSplit, similarityPath — first TableFunction registrations in
  the temporal subsystem (RegisterTnumberValueSplit /
  RegisterSimilarityPath split out from RegisterScalarFunctions).

setSRID / asMFJSON on tspatial:
- Tspatial_set_srid, Tspatial_as_mfjson.

Parity tests added:
- 025_temporal_tile.test (22 assertions) — tile / split surface
- 038_temporal_similarity.test (15 assertions) — Frechet / DTW / Hausdorff
- 064_tpoint_distance.test (7 assertions) — tdistance / NAI / NAD

Docs:
- docs/DuckDB-Parity-Gaps.md catalogs structural divergences (parser-
  rejected operators, GEOMETRY type-trip, SRS resolution) so future
  parity audits don't try to re-close them.

Suite: 796 assertions across 16 test cases passing (TZ=UTC).
@estebanzimanyi estebanzimanyi marked this pull request as ready for review May 1, 2026 19:13
nhungoc1508 pushed a commit that referenced this pull request May 4, 2026
scripts/parity-audit.py walks MobilityDB's CREATE FUNCTION surface
across mobilitydb/sql/**/*.in.sql and MobilityDuck's RegisterFunction
calls in src/**/*.cpp, then writes a per-section coverage table and a
list of unregistered function names.

Match is by name only — overload-level parity is not verified.

docs/parity-status.md is the latest snapshot. Regenerate with:

  python3 scripts/parity-audit.py --mdb ../MobilityDB --mduck . \
    --out docs/parity-status.md

Snapshot 2026-04-30: 1017/2054 names covered (49.5%). High-level
gaps include all aggregate sections, all gist/spgist support, the
*_compops / *_posops operator surfaces (where DuckDB-rejected
multi-char operators are partially covered by named-function
equivalents documented in docs/DuckDB-Parity-Gaps.md once PR #64
lands), and the npoint base type itself.
@estebanzimanyi

Copy link
Copy Markdown
Member Author

Superseded by the consolidated PR branch consolidate/tgeompoint-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