Skip to content

Attach the SQL-facing return type from the CREATE FUNCTION signatures#32

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/attach-sql-return-type
Jul 8, 2026
Merged

Attach the SQL-facing return type from the CREATE FUNCTION signatures#32
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/attach-sql-return-type

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Summary

Extends the SQL-facing signature attachment (which already gives each catalog function its sqlArity/sqlArityMax from the CREATE FUNCTION signatures) to also attach the SQL return type.

For the polymorphic Temporal *-returning functions the C signature is a bare Temporal *, which loses the concrete SQL subtype. A binding generator therefore cannot render the result type and must hand-special-case each one — against the single-source/zero-hand-case north star. Examples: getX/azimuth/speedtfloat, tDwithintbool, centroidtgeompoint (or tgeogpoint for temporal geographies).

Change

parser/sqlfn.py — in _wrapper_sql_sigs, parse the RETURNS <type> clause from the same CREATE FUNCTION name(args) RETURNS <type> AS 'MODULE_PATHNAME','<Wrapper>' statement already scanned for arity (it sits between the arg-list close and the AS), keyed by the wrapper. attach_sqlfn_map then attaches per function:

  • sqlReturnType — when the wrapper has a single SQL return type;
  • sqlReturnTypeAll — the sorted set when overloads legitimately differ (input-polymorphic wrappers: centroid{tgeompoint, tgeogpoint}, abs{tint, tfloat}, atValues → all subtypes).

The CREATE FUNCTION statement is the SoT; nothing is inferred from symbol names.

Effect

287 polymorphic Temporal * C-returns now carry a concrete SQL subtype in the catalog, so every binding (PyMEOS/JMEOS/MobilityDuck/Spark) can generate them without hand subtype maps.

Testing

All 147 parser tests pass (14 skipped); the existing sqlArity/sqlArityMax attachment is unchanged (temporal_as_hexwkb still (1, 2)).

The @sqlfn map + sqlArity give each catalog function its MobilityDB SQL
name and binding-facing arity, but not its binding-facing RETURN TYPE. For
the polymorphic Temporal *-returning functions the C signature is a bare
`Temporal *`, losing the concrete SQL subtype: getX/azimuth/speed return
tfloat, tDwithin returns tbool, centroid returns tgeompoint (tgeogpoint for
temporal geographies). Without this a binding generator cannot render the
SQL result type and must hand-special-case each one.

Parse the `RETURNS <type>` clause from the same CREATE FUNCTION statement
already scanned for arity (it sits between the arg-list close and the
`AS 'MODULE_PATHNAME','<Wrapper>'`), key by the wrapper, and attach:
  sqlReturnType     -- when the wrapper has a single SQL return type
  sqlReturnTypeAll  -- the sorted set when overloads differ (input-
                       polymorphic wrappers: centroid -> {tgeompoint,
                       tgeogpoint}, abs -> {tint, tfloat}, atValues -> ...)

287 polymorphic `Temporal *` C-returns now carry a concrete SQL subtype.
All 147 parser tests pass.
@estebanzimanyi estebanzimanyi merged commit 6d94c47 into MobilityDB:master Jul 8, 2026
2 checks passed
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