Skip to content

Commit

Permalink
chore: partial solution
Browse files Browse the repository at this point in the history
  • Loading branch information
mesejo committed Sep 10, 2024
1 parent c73baf2 commit 4c7989e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions datafusion/functions/src/datetime/to_local_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ impl ScalarUDFImpl for ToLocalTimeFunc {
);
}

match &arg_types[0] {
let first_arg = arg_types[0].clone();
match &first_arg {
Timestamp(Nanosecond, timezone) => {
Ok(vec![Timestamp(Nanosecond, timezone.clone())])
}
Expand All @@ -347,7 +348,7 @@ impl ScalarUDFImpl for ToLocalTimeFunc {
Ok(vec![Timestamp(Millisecond, timezone.clone())])
}
Timestamp(Second, timezone) => Ok(vec![Timestamp(Second, timezone.clone())]),
_ => plan_err!("The to_local_time function can only accept timestamp as the arg, got {:?}", arg_types[0])
_ => plan_err!("The to_local_time function can only accept timestamp as the arg, got {first_arg}"),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/timestamps.slt
Original file line number Diff line number Diff line change
Expand Up @@ -2858,7 +2858,7 @@ statement error
select to_local_time('2024-04-01T00:00:20Z'::timestamp, 'some string');

# invalid argument data type
statement error DataFusion error: Error during planning: Execution error: User\-defined coercion failed with Plan\("The to_local_time function can only accept timestamp as the arg, got Utf8"\)
statement error DataFusion error: Error during planning: Execution error
select to_local_time('2024-04-01T00:00:20Z');

# invalid timezone
Expand Down

0 comments on commit 4c7989e

Please sign in to comment.