Skip to content

Add ScalarUDFs in missing function hints / suggested errors #9392

@alamb

Description

@alamb

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)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions