Jefffrey commented on code in PR #19540:
URL: https://github.com/apache/datafusion/pull/19540#discussion_r2654489649


##########
datafusion/sqllogictest/test_files/datetime/timestamps.slt:
##########
@@ -3285,6 +3285,199 @@ select make_time(22, 1, '');
 query error Expect TypeSignatureClass::Native\(LogicalType\(Native\(Int32\), 
Int32\)\) but received NativeType::Float64, DataType: Float64
 select make_time(arrow_cast(22, 'Float64'), 1, '');
 
+##########
+## to_time tests
+##########
+
+# Basic time parsing
+
+query D
+select to_time('12:30:45');
+----
+12:30:45
+
+query D
+select to_time('00:00:00');
+----
+00:00:00
+
+query D
+select to_time('23:59:59');
+----
+23:59:59
+
+query D
+select to_time('08:15:30');
+----
+08:15:30
+
+# Time with fractional seconds
+
+query D
+select to_time('12:30:45.123');
+----
+12:30:45.123
+
+query D
+select to_time('12:30:45.123456789');
+----
+12:30:45.123456789
+
+# Time with custom format
+
+query D
+select to_time('12-30-45', '%H-%M-%S');
+----
+12:30:45
+
+query D
+select to_time('14/25/30', '%H/%M/%S');
+----
+14:25:30
+
+query D
+select to_time('02:30:45 PM', '%I:%M:%S %p');
+----
+14:30:45
+
+# Null handling
+
+query D
+select to_time(null);
+----
+NULL
+
+# Return type check
+
+query T
+select arrow_typeof(to_time('12:30:45'));
+----
+Time64(ns)
+
+# Table input
+
+statement ok
+create table time_strings (time_str varchar) as values
+    ('12:30:45'),
+    ('23:59:59'),
+    ('00:00:00');
+
+query D
+select to_time(time_str) from time_strings;
+----
+12:30:45
+23:59:59
+00:00:00
+
+statement ok
+drop table time_strings;
+
+# Error cases
+
+query error Error parsing 'not_a_time' as time
+select to_time('not_a_time');
+
+query error Error parsing '25:00:00' as time
+select to_time('25:00:00');
+
+# Out of range minutes
+query error Error parsing '12:60:00' as time
+select to_time('12:60:00');
+
+# Out of range seconds (61 is invalid, 60 is allowed as leap second)
+query error Error parsing '12:30:61' as time
+select to_time('12:30:61');
+
+query error does not support zero arguments
+select to_time();
+
+# HH:MM default parsing (no seconds)
+
+query D
+select to_time('14:30');
+----
+14:30:00
+
+query D
+select to_time('09:05');
+----
+09:05:00
+
+query D
+select to_time('00:00');
+----
+00:00:00
+
+# Timestamp input - extract time portion
+
+query D
+select to_time(to_timestamp('2024-01-15 14:30:45'));
+----
+14:30:45
+
+query D
+select to_time('2024-03-20 09:15:30'::timestamp);
+----
+09:15:30
+
+query D
+select to_time('2024-06-15 23:59:59.123456789'::timestamp);
+----
+23:59:59.123456789
+
+query D
+select to_time('2024-01-01 00:00:00'::timestamp);
+----
+00:00:00
+
+# Timestamp with timezone
+
+query D
+select to_time(to_timestamp('2024-01-15T14:30:45+00:00'));
+----
+14:30:45
+
+# Null timestamp
+
+query D
+select to_time(null::timestamp);
+----
+NULL
+
+# Return type check with timestamp input
+
+query T
+select arrow_typeof(to_time(to_timestamp('2024-01-15 12:30:45')));
+----
+Time64(ns)
+
+# Timestamp with non-UTC timezone (America/New_York = -05:00)
+
+query D
+select to_time(to_timestamp('2024-01-15T14:30:45-05:00'));
+----
+19:30:45
+
+# Timezone test using timestamp value directly
+# The timestamp is converted from -05:00 to UTC, so 14:30:45-05:00 = 19:30:45 
UTC
+
+query D
+select to_time('2024-03-20 09:15:30'::timestamp AT TIME ZONE 
'America/Los_Angeles');
+----
+09:15:30

Review Comment:
   Sorry I can't understand what the reply means here in relation to my question



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to