-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed