Attach the SQL-facing arity from the CREATE FUNCTION signatures#31
Merged
Merged
Conversation
The @sqlfn map gives each catalog function its MobilityDB SQL name, but the binding-facing ARITY is the SQL CREATE FUNCTION signature, not the wider C one. A SQL arg with a DEFAULT clause is optional, and a trailing C parameter absent from the SQL form is a C-only out-param (e.g. the size_t * of the *_as_hexwkb family). Without this a generator emits the raw C arity — trajectory(temporal, bool) instead of SQL trajectory(temporal), or asHexWKB(temporal, byte, <out>) instead of asHexWKB(temporal) — forcing every binding to hand-special-case the flag and out-params. Parse mobilitydb/sql/**/*.in.sql for `CREATE FUNCTION name(args) ... AS 'MODULE_PATHNAME','<Wrapper>'`, key by the wrapper (the @csqlfn target), and attach per function: sqlArity -- required SQL args (no DEFAULT) sqlArityMax -- total SQL args (including DEFAULT) so a generator derives: C params [0, sqlArity) required, [sqlArity, sqlArityMax) SQL-optional, [sqlArityMax, C-arity) out-params. 1977 wrappers parsed, 185 with optional args; trajectory -> (1, 2), temporal_as_hexwkb -> (1, 2) over a 3-param C signature (the size_out is the lone out-param).
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.
The
@sqlfnmap gives each catalog function its MobilityDB SQL name, but the binding-facing arity is the SQLCREATE FUNCTIONsignature, not the wider C one. A SQL arg with aDEFAULTclause is optional, and a trailing C parameter absent from the SQL form is a C-only out-param (e.g. thesize_t *of the*_as_hexwkbfamily). Without this a generator emits the raw C arity —trajectory(temporal, bool)instead of SQLtrajectory(temporal), orasHexWKB(temporal, byte, <out>)instead ofasHexWKB(temporal)— forcing every binding to hand-special-case the flag and out-params (which the codegen North Star forbids).What
parser/sqlfn.pyparsesmobilitydb/sql/**/*.in.sqlforCREATE FUNCTION name(args) ... AS 'MODULE_PATHNAME','<Wrapper>', keys by the wrapper (the@csqlfntarget), and attaches per function:sqlArity— required SQL args (noDEFAULT)sqlArityMax— total SQL args (includingDEFAULT)so a generator derives: C params
[0, sqlArity)required,[sqlArity, sqlArityMax)SQL-optional,[sqlArityMax, C-arity)out-params.run.pywires themobilitydb/sqlsource root into the@sqlfnstep.On the current master surface: 2513 functions receive
sqlArity/sqlArityMax;tpoint_trajectory → (1, 2),temporal_as_hexwkb → (1, 2)over its 3-param C signature (thesize_outis the lone out-param).Why now
The catalog previously lost this enrichment, so consumers that key UDF/binding arity off it regressed. Proven end-to-end: with this restored, MobilitySpark's generated
trajectoryUDF registers as the SQL-faithfulUDF1(wasUDF2) and its suite goes green — with no hand special-case in the binding.