Skip to content

Commit

Permalink
chore: clone time_value
Browse files Browse the repository at this point in the history
  • Loading branch information
appletreeisyellow committed Jul 9, 2024
1 parent 3456517 commit b8be3b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion datafusion/functions/src/datetime/to_local_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl ToLocalTimeFunc {
match array.data_type() {
Timestamp(_, None) => {
// if no timezone specificed, just return the input
Ok(ColumnarValue::Array(Arc::clone(array)))
Ok(time_value.clone())
}
Timestamp(Nanosecond, Some(_)) => {
transform_array::<TimestampNanosecondType>(array, tz)
Expand Down
18 changes: 17 additions & 1 deletion datafusion/sqllogictest/test_files/timestamps.slt
Original file line number Diff line number Diff line change
Expand Up @@ -2932,6 +2932,22 @@ create view t_timezone as
select column1::timestamp AT TIME ZONE 'Europe/Brussels' as "column1"
from t;

query PPT
select column1, to_local_time(column1::timestamp), arrow_typeof(to_local_time(column1::timestamp)) from t_utc;
----
2024-01-01T00:00:01Z 2024-01-01T00:00:01 Timestamp(Nanosecond, None)
2024-02-01T00:00:01Z 2024-02-01T00:00:01 Timestamp(Nanosecond, None)
2024-03-01T00:00:01Z 2024-03-01T00:00:01 Timestamp(Nanosecond, None)
2024-04-01T00:00:01Z 2024-04-01T00:00:01 Timestamp(Nanosecond, None)
2024-05-01T00:00:01Z 2024-05-01T00:00:01 Timestamp(Nanosecond, None)
2024-06-01T00:00:01Z 2024-06-01T00:00:01 Timestamp(Nanosecond, None)
2024-07-01T00:00:01Z 2024-07-01T00:00:01 Timestamp(Nanosecond, None)
2024-08-01T00:00:01Z 2024-08-01T00:00:01 Timestamp(Nanosecond, None)
2024-09-01T00:00:01Z 2024-09-01T00:00:01 Timestamp(Nanosecond, None)
2024-10-01T00:00:01Z 2024-10-01T00:00:01 Timestamp(Nanosecond, None)
2024-11-01T00:00:01Z 2024-11-01T00:00:01 Timestamp(Nanosecond, None)
2024-12-01T00:00:01Z 2024-12-01T00:00:01 Timestamp(Nanosecond, None)

query PPT
select column1, to_local_time(column1), arrow_typeof(to_local_time(column1)) from t_utc;
----
Expand Down Expand Up @@ -3004,4 +3020,4 @@ statement ok
drop view t_utc;

statement ok
drop view t_timezone;
drop view t_timezone;

0 comments on commit b8be3b1

Please sign in to comment.