Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ScalarUDFs in missing function hints / suggested errors #9392

Closed
alamb opened this issue Feb 28, 2024 · 2 comments · Fixed by #9407
Closed

Add ScalarUDFs in missing function hints / suggested errors #9392

alamb opened this issue Feb 28, 2024 · 2 comments · Fixed by #9407
Assignees
Labels
enhancement New feature or request

Comments

@alamb
Copy link
Contributor

alamb commented Feb 28, 2024

Is your feature request related to a problem or challenge?

Part of #8045

Today there is a nice error message with a hint if a user issues an unknown function

For example, tryng cos2 will have datafusion suggest cos

DataFusion CLI v36.0.0
❯ select cos2(1);
Error during planning: Invalid function 'cos2'.
Did you mean 'cos'?

However, UDFs are never suggested

For example, the function abs has been moved to a ScalarUDF, so now the error message does not suggest this.

DataFusion CLI v36.0.0select abs2(1);
Error during planning: Invalid function 'abs2'.
Did you mean 'acos'?

but in earlier versions of DataFusion where abs was a built in function, it is correctly suggested:

DataFusion CLI v32.0.0select abs2(1);
Error during planning: Invalid function 'abs2'.
Did you mean 'abs'?

Describe the solution you'd like

I would like UDFs to be included in the suggestsed the error message

Describe alternatives you've considered

Here is where the suggestion is created: https://github.com/apache/arrow-datafusion/blob/cf69d38e80448ec7402f622d2adcfc6edf0b387e/datafusion/sql/src/expr/function.rs#L214-L215

I think it will be a fairly straightforward exercise to extend the list in https://github.com/apache/arrow-datafusion/blob/cf69d38e80448ec7402f622d2adcfc6edf0b387e/datafusion/expr/src/function.rs#L80-L94 to

Additional context

This came up in the context of #9388, #9388 (comment)

@alamb alamb added the enhancement New feature or request label Feb 28, 2024
@alamb alamb changed the title Add function hints for ScalarUDFs Add ScalarUDFs in missing function hints Feb 28, 2024
@SteveLauC
Copy link
Contributor

Nice feature, I would like to try this as I have never touched the sql crate😁

take

@SteveLauC
Copy link
Contributor

take

@alamb alamb changed the title Add ScalarUDFs in missing function hints Add ScalarUDFs in missing function hints / suggested errors Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants