Skip to content

Commit

Permalink
Fix an issue with to_char signature not working correctly with timezo…
Browse files Browse the repository at this point in the history
…nes or other types because the ordering is not in most exact -> least exact order. (apache#13126)
  • Loading branch information
Omega359 authored Oct 29, 2024
1 parent c03e260 commit 1c2a2fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
24 changes: 12 additions & 12 deletions datafusion/functions/src/datetime/to_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,34 @@ impl ToCharFunc {
vec![
Exact(vec![Date32, Utf8]),
Exact(vec![Date64, Utf8]),
Exact(vec![Time64(Nanosecond), Utf8]),
Exact(vec![Time64(Microsecond), Utf8]),
Exact(vec![Time32(Millisecond), Utf8]),
Exact(vec![Time32(Second), Utf8]),
Exact(vec![Time64(Microsecond), Utf8]),
Exact(vec![Time64(Nanosecond), Utf8]),
Exact(vec![Timestamp(Second, None), Utf8]),
Exact(vec![
Timestamp(Second, Some(TIMEZONE_WILDCARD.into())),
Timestamp(Nanosecond, Some(TIMEZONE_WILDCARD.into())),
Utf8,
]),
Exact(vec![Timestamp(Millisecond, None), Utf8]),
Exact(vec![Timestamp(Nanosecond, None), Utf8]),
Exact(vec![
Timestamp(Millisecond, Some(TIMEZONE_WILDCARD.into())),
Timestamp(Microsecond, Some(TIMEZONE_WILDCARD.into())),
Utf8,
]),
Exact(vec![Timestamp(Microsecond, None), Utf8]),
Exact(vec![
Timestamp(Microsecond, Some(TIMEZONE_WILDCARD.into())),
Timestamp(Millisecond, Some(TIMEZONE_WILDCARD.into())),
Utf8,
]),
Exact(vec![Timestamp(Nanosecond, None), Utf8]),
Exact(vec![Timestamp(Millisecond, None), Utf8]),
Exact(vec![
Timestamp(Nanosecond, Some(TIMEZONE_WILDCARD.into())),
Timestamp(Second, Some(TIMEZONE_WILDCARD.into())),
Utf8,
]),
Exact(vec![Duration(Second), Utf8]),
Exact(vec![Duration(Millisecond), Utf8]),
Exact(vec![Duration(Microsecond), Utf8]),
Exact(vec![Timestamp(Second, None), Utf8]),
Exact(vec![Duration(Nanosecond), Utf8]),
Exact(vec![Duration(Microsecond), Utf8]),
Exact(vec![Duration(Millisecond), Utf8]),
Exact(vec![Duration(Second), Utf8]),
],
Volatility::Immutable,
),
Expand Down
5 changes: 5 additions & 0 deletions datafusion/sqllogictest/test_files/timestamps.slt
Original file line number Diff line number Diff line change
Expand Up @@ -2780,6 +2780,11 @@ FROM
NULL
01:01:2025 23-59-58

query T
select to_char('2020-01-01 00:10:20.123'::timestamp at time zone 'America/New_York', '%Y-%m-%d %H:%M:%S.%3f');
----
2020-01-01 00:10:20.123

statement ok
drop table formats;

Expand Down

0 comments on commit 1c2a2fd

Please sign in to comment.