Skip to content

Capture SQL argument defaults in the per-overload signatures#40

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/sql-arg-defaults
Jul 10, 2026
Merged

Capture SQL argument defaults in the per-overload signatures#40
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/sql-arg-defaults

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

A CREATE FUNCTION with an optional trailing argument (integer DEFAULT 0, text DEFAULT NULL) is SQL-callable at the shorter arity, but the catalog carried only the arity count (sqlArity < sqlArityMax), never the value to substitute. A binding could pass a null pointer for an omitted DEFAULT NULL argument, but had no way to render a by-value default such as round's precision 0.

This captures the literal default per argument, verbatim from the SQL, as argDefaults on each sqlSignatures entry (None for a required argument):

set_round -> [{'args': ['floatset', 'integer'], 'ret': 'floatset', 'argDefaults': [null, '0']}, ...]
floatset_degrees -> [{'args': ['floatset', 'bool'], 'ret': 'floatset', 'argDefaults': [null, 'FALSE']}]

_arg_default is the exact complement of _bare_type (same split, the other side), so the value is taken straight from the declaration with no interpretation. The field is attached only to signatures that have an optional argument, so default-free signatures stay {args, ret} unchanged — 141 of 2202 functions with signatures gain the field, the rest are byte-identical.

A binding can now emit the shorter overload of a SQL-optional argument with its declared value (round(floatset) rounding to 0 decimals) instead of hand-registering it.

Adds tests/test_sql_defaults.py; full suite 160 passed, 8 skipped.

A CREATE FUNCTION with an optional trailing argument (integer DEFAULT 0, text DEFAULT NULL) is SQL-callable at the shorter arity, but the catalog carried only the arity count (sqlArity < sqlArityMax), not the value to substitute. A binding could pass a null pointer for an omitted DEFAULT NULL argument, but had no way to render a by-value default such as round's precision 0.

Capture the literal default per argument, verbatim from the SQL, as argDefaults on each sqlSignatures entry (None for a required argument). The value is attached only to signatures that have an optional argument, so default-free signatures are unchanged; 141 of 2202 functions with signatures gain the field. A binding now emits the shorter overload of an optional argument with its declared value (round(floatset) rounding to 0 decimals) instead of hand-registering it.
estebanzimanyi added a commit to MobilityDB/MobilityDuck that referenced this pull request Jul 10, 2026
The catalog now carries the SQL DEFAULT of an optional argument as argDefaults on each sqlSignatures entry (round(floatset, integer DEFAULT 0) -> argDefaults [null, "0"]). The set generator reads it: a scalar-param set function with an optional trailing argument also emits the shorter overload, substituting the declared default (round(floatset) -> set_round(s, 0)), alongside the existing full-arity round(floatset, integer).

Both arities are now generated, so the hand SetFunctions::Floatset_round registration, body and declaration are removed. The vendored catalog is regenerated at the same MobilityDB REF (de560130); its only change is the additive argDefaults field. Consumes MobilityDB/MEOS-API#40.
@estebanzimanyi estebanzimanyi merged commit 5e13929 into MobilityDB:master Jul 10, 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