r1b opened a new pull request, #18450:
URL: https://github.com/apache/datafusion/pull/18450
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases. You can
link an issue to this PR using the GitHub syntax. For example `Closes #123`
indicates that this PR will close issue #123.
-->
- Closes #17887.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in
the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your
changes and offer better suggestions for fixes.
-->
See linked issue above
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is
sometimes worth providing a summary of the individual changes in this PR.
-->
- Add validation when planning `CreateFunction`
- Enforce consistent parameter style (positional or named)
- Non-default params cannot follow default params
- `CreateFunction` parameter names are now preserved from the parse tree
- If we encounter a named parameter when constructing a `Placeholder`
- We try to rewrite this to a positional parameter from the available
param types
- If no matching param type is found, report an error
- Update `ScalarFunctionWrapper` to handle defaults
- Preserve the parsed defaults
- Generate all valid signatures for all possible combinations of arguments
- Fall back to default expr when no matching argument is provided
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are
they covered by existing tests)?
-->
Yes, see added / adjusted unit tests
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
Yes, if the approach here is acceptable we should update the SQL UDF
examples in `datafusion-examples/examples/function_factory.rs` (TODO).
Also, note that due to ambiguity between `PREPARE` and `CREATE FUNCTION`
param context one error message now has reduced fidelity.
> Invalid placeholder, not a number: $foo
This can now be triggered either by using named params in a prepared
statement or when referencing an undefined named param in a SQL UDF. New
message:
> Invalid placeholder: $foo
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]