logan-keede opened a new issue, #14448:
URL: https://github.com/apache/datafusion/issues/14448
### Describe the bug
I was trying to make some changes to a function in `datafusion-functions`
crate specifically in `to_timestamp_impl` function when I noticed that it is
being called 7 times for query `SELECT to_timestamp('2020-09-08
12/00/00+00:00');`
This does not seem expected and it is probably causing efficiency drops and
problems while troubleshooting bugs in functions.
This only seems to happen for function calls that are going to generate
error anyways.
so far this has been replicated in `to_timestamp` and `to_char` but it can
be probably be replicated in other functions too.
### To Reproduce
edit `invoke_batch` function in implementation of `ScalarUDFImpl` trait
for struct `ToTimestampFunc` to include a logging statement like
```
fn invoke_batch(
&self,
args: &[ColumnarValue],
_number_rows: usize,
) -> Result<ColumnarValue> {
println!("to_timestamp_impl is being called");
```
then in datafusion-cli
```
> select to_timestamp('1');
to_timestamp_impl is being called
to_timestamp_impl is being called
to_timestamp_impl is being called
to_timestamp_impl is being called
to_timestamp_impl is being called
to_timestamp_impl is being called
to_timestamp_impl is being called
Arrow error: Parser error: Error parsing timestamp from '1': timestamp must
contain at least 10 characters
> select to_timestamp('2023-01-31T09:26:56-05:00', '%+');
to_timestamp_impl is being called
+------------------------------------------------------------+
| to_timestamp(Utf8("2023-01-31T09:26:56-05:00"),Utf8("%+")) |
+------------------------------------------------------------+
| 2023-01-31T14:26:56 |
+------------------------------------------------------------+
1 row(s) fetched.
Elapsed 0.005 seconds.
> select to_char('1'::time, '%Y-%m-%d');
to_char is being called
to_char is being called
to_char is being called
to_char is being called
to_char is being called
to_char is being called
to_char is being called
to_char is being called
to_char is being called
to_char is being called
to_char is being called
to_char is being called
to_char is being called
Execution error: Cast error: Format error
```
### Expected behavior
```
> select to_timestamp('1', '%d');
to_timestamp_impl is being called
Arrow error: Parser error: Error parsing timestamp from '1': timestamp must
contain at least 10 characters
> select to_char('1'::time, '%Y-%m-%d');
to_char is being called
Execution error: Cast error: Format error
```
### Additional context
_No response_
--
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]