Skip to content

Commit

Permalink
adding sqllogictests
Browse files Browse the repository at this point in the history
  • Loading branch information
Omega359 committed Feb 9, 2024
1 parent c2a239a commit dbbaded
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions datafusion/sqllogictest/test_files/timestamps.slt
Original file line number Diff line number Diff line change
Expand Up @@ -2565,3 +2565,86 @@ select make_date(2024, 1, null);

query error DataFusion error: Arrow error: Cast error: Cannot cast string '' to value of Int32 type
select make_date(2024, 1, '');


##########
## to_char tests
##########

statement ok
create table formats (
dates date,
timestamps timestamp,
date_format varchar,
timestamp_format varchar)
as values
('2000-01-01'::date, '2024-01-01 06:00:00'::timestamp, '%d:%m:%Y', '%d:%m:%Y %H-%M-%S'),
('2003-04-05'::date, '2025-01-01 23:59:58'::timestamp, '%d:%m:%Y', '%d:%m:%Y %H-%M-%S');


query T
select to_char(dates, date_format) from formats;
----
01:01:2000
05:04:2003

query T
select date_format(dates, date_format) from formats;
----
01:01:2000
05:04:2003

query T
select to_char(timestamps, date_format) from formats;
----
01:01:2024
01:01:2025

query T
select to_char(timestamps, timestamp_format) from formats;
----
01:01:2024 06-00-00
01:01:2025 23-59-58

query T
select to_char('2000-02-03'::date, '%Y:%d:%m');
----
2000:03:02

query T
select to_char(arrow_cast(TIMESTAMP '2023-08-03 14:38:50Z', 'Timestamp(Second, None)'), '%d-%m-%Y %H-%M-%S')
----
03-08-2023 14-38-50

query T
select to_char(arrow_cast(123456, 'Duration(Second)'), 'pretty');
----
1 days 10 hours 17 mins 36 secs

query T
select to_char(arrow_cast(123456, 'Duration(Second)'), 'iso8601');
----
P1DT37056S

query T
select to_char(arrow_cast(123456, 'Duration(Second)'), null);
----
1 days 10 hours 17 mins 36 secs

# this panics with a unhandled internal error in arrow-rs code
#query error
#SELECT to_char(timestamps, '%X%K') from formats;

query T
SELECT to_char(timestamps, null) from formats;
----
(empty)
(empty)

query T
SELECT to_char(null, '%d-%m-%Y');
----
(empty)

statement ok
drop table formats;

0 comments on commit dbbaded

Please sign in to comment.