Skip to content
This repository was archived by the owner on May 10, 2026. It is now read-only.
This repository was archived by the owner on May 10, 2026. It is now read-only.

Align function names and fix NAD sentinel for cross-platform SQL portability #1

@estebanzimanyi

Description

@estebanzimanyi

Background

MobilityDB Discussion #861 proposes a portable SQL dialect that runs the same query unchanged on MobilityDB/PostgreSQL, MobilityDuck/DuckDB, and MobilitySpark/Spark (see also MobilitySpark RFC #3).

MobilityPySpark has two gaps that block portability:

1 — Function name mismatches

MobilityPySpark uses Python-style names that differ from the MEOS/MobilityDB canonical names. The portable dialect requires canonical names so the same SQL runs on all three platforms:

MobilityPySpark (current) Canonical (MEOS / MobilityDB)
tpoint_at(trip, instant) atTime(trip, instant)
ever_intersects(trip, geom) eIntersects(trip, geom)
min_distance(t1, t2) / nearest_approach_distance(t1, t2) nearestApproachDistance(t1, t2)
at_period(trip, period) atTime(trip, tstzspan)
at_geom(trip, geom) atGeometry(trip, geom)

2 — NAD failure sentinel (blocks Q5 portability)

nearestApproachDistance / min_distance currently returns -1.0 on failure. The MEOS C layer uses DBL_MAX (established in MobilityDB PR #846); at the SQL level the canonical value is NULL.

Any UDF wrapper must convert the internal failure sentinel to None (→ SQL NULL) before returning. The -1.0 convention pre-dates PR #846 and should be retired.

Proposed fix

Rename UDFs to canonical names in pysparkmeos/UDF/udf.py and fix the NAD sentinel. Aliases for backward compatibility are optional but the canonical names must be the primary registered names.

This is the concrete change that unblocks BerlinMOD Q5 on MobilityPySpark.

cc @Action52

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions