Attach the SQL-facing return type from the CREATE FUNCTION signatures#32
Merged
estebanzimanyi merged 1 commit intoJul 8, 2026
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the SQL-facing signature attachment (which already gives each catalog function its
sqlArity/sqlArityMaxfrom theCREATE FUNCTIONsignatures) to also attach the SQL return type.For the polymorphic
Temporal *-returning functions the C signature is a bareTemporal *, 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/speed→tfloat,tDwithin→tbool,centroid→tgeompoint(ortgeogpointfor temporal geographies).Change
parser/sqlfn.py— in_wrapper_sql_sigs, parse theRETURNS <type>clause from the sameCREATE FUNCTION name(args) RETURNS <type> AS 'MODULE_PATHNAME','<Wrapper>'statement already scanned for arity (it sits between the arg-list close and theAS), keyed by the wrapper.attach_sqlfn_mapthen 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 FUNCTIONstatement 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/sqlArityMaxattachment is unchanged (temporal_as_hexwkbstill(1, 2)).