Co-locate function parameter names and types with Signature::with_parameters
#19524
+259
−11
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.
Which issue does this PR close?
Rationale for this change
Function signatures in DataFusion currently define parameter types/coercions and parameter names in separate places (e.g.
TypeSignature::Coercible(...)plus a later.with_parameter_names(...)). This separation makes signatures harder to read and increases the risk of names and types getting out of sync during maintenance.This PR introduces an ergonomic builder API that lets authors define parameter names together with their expected
DataTypeorCoercionrules in one place, improving readability and reducing duplication.What changes are included in this PR?
Added a new helper enum
ParameterKindto represent either:DataType(forTypeSignature::ExactandTypeSignature::Uniform), orCoercionrule (forTypeSignature::Coercible).Added
Signature::with_parameter(...)andSignature::with_parameters(...)builder methods to:store parameter names on the signature,
validate arity consistently via existing validation,
populate the underlying
TypeSignaturewhere applicable:Exact: fills/overwrites the type list (with arity checks when already set)Coercible: fills/overwrites coercion rules (with arity checks when already set)Uniform: validates that provided types are among the allowed types and validates arityreject unsupported cases (e.g. variable arity signatures) via existing validation.
Refactored
unicode::substrsignature construction to use.with_parameters(&[...]), co-locating parameter names with their coercion rules.Added unit tests covering:
Exact,Coercible, andUniformusageAre these changes tested?
Yes.
signature.rsvalidating correct behavior and error cases forwith_parameters.substrrefactor is a mechanical adoption of the new API.Are there any user-facing changes?
No user-facing behavior changes are intended.
This is a developer-facing refactor / ergonomics improvement for defining function signatures. Function semantics and runtime behavior should remain the same.
LLM-generated code disclosure
This PR includes LLM-generated code and comments. All LLM-generated content has been manually reviewed and tested.