Skip to content

A way to specify constant/scalar arguments in UDFs #24133

Description

@Jefffrey

Is your feature request related to a problem or challenge?

Some UDFs may expect a constant/scalar/literal argument, and not allow array inputs.

For example, arrow_cast:

type_arg
.and_then(|sv| sv.try_as_str().flatten().filter(|s| !s.is_empty()))
.map_or_else(
|| {
exec_err!(
"{} requires its second argument to be a non-empty constant string",
self.name()
)
},
|casted_type| match casted_type.parse::<DataType>() {
Ok(data_type) => Ok(Field::new(self.name(), data_type, nullable).into()),
Err(ArrowError::ParseError(e)) => Err(exec_datafusion_err!("{e}")),
Err(e) => Err(arrow_datafusion_err!(e)),
},
)

Describe the solution you'd like

Some way to specify this at the signature level instead of needing this manual handling. This can then centralize the logic across the functions that need this.

Describe alternatives you've considered

No response

Additional context

Perhaps wire it only into the coercible signatures?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions