From 4c7989e21d96925061effa4f6c589143c92f9b3b Mon Sep 17 00:00:00 2001 From: Daniel Mesejo Date: Tue, 10 Sep 2024 15:34:35 +0200 Subject: [PATCH] chore: partial solution --- datafusion/functions/src/datetime/to_local_time.rs | 5 +++-- datafusion/sqllogictest/test_files/timestamps.slt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/datafusion/functions/src/datetime/to_local_time.rs b/datafusion/functions/src/datetime/to_local_time.rs index 102e947a5836..5f8f5ceeae08 100644 --- a/datafusion/functions/src/datetime/to_local_time.rs +++ b/datafusion/functions/src/datetime/to_local_time.rs @@ -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())]) } @@ -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}"), } } } diff --git a/datafusion/sqllogictest/test_files/timestamps.slt b/datafusion/sqllogictest/test_files/timestamps.slt index 9ffe22327f50..6f7f6645005e 100644 --- a/datafusion/sqllogictest/test_files/timestamps.slt +++ b/datafusion/sqllogictest/test_files/timestamps.slt @@ -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