You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Jefffrey (via GitHub)" <gi...@apache.org> on 2026/08/06 05:32:23 UTC

[I] A way to specify constant/scalar arguments in UDFs [datafusion]

Jefffrey opened a new issue, #24133:
URL: https://github.com/apache/datafusion/issues/24133

   ### 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`:
   
   https://github.com/apache/datafusion/blob/f27e50c13647efa5292d5ef5b1e4ed6af3015962/datafusion/functions/src/core/arrow_cast.rs#L134-L148
   
   ### 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?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] A way to specify constant/scalar arguments in UDFs [datafusion]

Posted by "getChan (via GitHub)" <gi...@apache.org>.
getChan commented on issue #24133:
URL: https://github.com/apache/datafusion/issues/24133#issuecomment-5229984683

   I think there are three possible places to model the constant/literal-argument requirement:
   
   | Design | Pros | Cons |
   | --- | --- | --- |
   | Add `is_scalar` / `is_literal` to `Coercion` | Small implementation change; reuses the existing coercible-signature flow | Mixes type coercion with expression/value constraints; `Coercion` becomes responsible for more than type conversion |
   | Add argument constraints to `Signature` | Keeps type coercion separate from value constraints; clear for functions where the same argument constraint applies to every accepted type alternative | Less suitable if different `OneOf` alternatives need different constraints |
   | Add constraints to the argument definitions inside `TypeSignature` | Most expressive; constraints can vary per signature alternative and per argument | Larger API and migration cost; more implementation work |
   
   For the current use cases (`arrow_cast`, `arrow_try_cast`, and `date_part`), the literal requirement appears to be common across all accepted alternatives. Therefore, an argument-constraint member on `Signature` seems like the cleanest option for this issue.
   
   If we want to support alternatives with different literal requirements in the future, the constraint should instead live with each argument in the `TypeSignature` alternative.
   
   Also, the current check is specifically for `Expr::Literal`, so `literal` or `constant` may be a more precise name than `scalar`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] A way to specify constant/scalar arguments in UDFs [datafusion]

Posted by "getChan (via GitHub)" <gi...@apache.org>.
getChan commented on issue #24133:
URL: https://github.com/apache/datafusion/issues/24133#issuecomment-5225784142

   take


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] A way to specify constant/scalar arguments in UDFs [datafusion]

Posted by "getChan (via GitHub)" <gi...@apache.org>.
getChan commented on issue #24133:
URL: https://github.com/apache/datafusion/issues/24133#issuecomment-6294236152

   untake


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] A way to specify constant/scalar arguments in UDFs [datafusion]

Posted by "dd-annarose (via GitHub)" <gi...@apache.org>.
dd-annarose commented on issue #24133:
URL: https://github.com/apache/datafusion/issues/24133#issuecomment-5283299605

   sorry I started working on it without checking the existing issues... 😅


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org