capkurmagati opened a new issue #1239:
URL: https://github.com/apache/arrow-datafusion/issues/1239
**Describe the bug**
Some `BuiltinScalarFunction` panic with no argument provided.
**To Reproduce**
```
DataFusion CLI v5.1.0-SNAPSHOT
> select lower();
thread 'main' panicked at 'index out of bounds: the len is 0 but the index
is 0', datafusion/src/physical_plan/functions.rs:534:59
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
DataFusion CLI v5.1.0-SNAPSHOT
> select to_timestamp();
thread 'main' panicked at 'index out of bounds: the len is 0 but the index
is 0', datafusion/src/physical_plan/functions.rs:1144:28
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
**Expected behavior**
Instead of panic, the client should get an error with proper error messages.
```
postgres=# select lower();
ERROR: function lower() does not exist
LINE 1: select lower();
^
HINT: No function matches the given name and argument types. You might need
to add explicit type casts.
postgres=# select to_timestamp();
ERROR: function to_timestamp() does not exist
LINE 1: select to_timestamp();
^
HINT: No function matches the given name and argument types. You might need
to add explicit type casts.
```
**Additional context**
There two places in `datafusion/src/physical_plan/functions.rs` that could
be fixed.
1. `return_type`
https://github.com/apache/arrow-datafusion/blob/master/datafusion/src/physical_plan/functions.rs#L532-L537
2. `create_physical_expr`
https://github.com/apache/arrow-datafusion/blob/master/datafusion/src/physical_plan/functions.rs#L1144
Index are used without check.
One possible solution will be checking the length of the arg like here
https://github.com/apache/arrow-datafusion/blob/master/datafusion/src/physical_plan/functions.rs#L625-L630.
Or to change the `match` statement to not only match the function name but
the function signature.
--
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]