Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanc-n committed Nov 20, 2024
1 parent 53107f5 commit 42817e6
Showing 1 changed file with 195 additions and 0 deletions.
195 changes: 195 additions & 0 deletions datafusion/sqllogictest/test_files/group_by.slt
Original file line number Diff line number Diff line change
Expand Up @@ -5271,3 +5271,198 @@ drop view t

statement ok
drop table source;

# Test multi group by int + Date32
statement ok
create table source as values
(1, '2020-01-01'),
(1, '2020-01-01'),
(2, '2020-01-02'),
(2, '2020-01-03'),
(3, '2020-01-04'),
(3, '2020-01-04'),
(2, '2020-01-03'),
(null, null),
(null, '2020-01-01'),
(null, null),
(null, '2020-01-01'),
(2, '2020-01-02'),
(2, '2020-01-02'),
(1, null)
;

statement ok
create view t as select column1 as a, arrow_cast(column2, 'Date32') as b from source;

query IDI
select a, b, count(*) from t group by a, b order by a, b;
----
1 2020-01-01 2
1 NULL 1
2 2020-01-02 3
2 2020-01-03 2
3 2020-01-04 2
NULL 2020-01-01 2
NULL NULL 2

statement ok
drop view t

statement ok
drop table source;

# Test multi group by int + Date64
statement ok
create table source as values
(1, '2020-01-01'),
(1, '2020-01-01'),
(2, '2020-01-02'),
(2, '2020-01-03'),
(3, '2020-01-04'),
(3, '2020-01-04'),
(2, '2020-01-03'),
(null, null),
(null, '2020-01-01'),
(null, null),
(null, '2020-01-01'),
(2, '2020-01-02'),
(2, '2020-01-02'),
(1, null)
;

statement ok
create view t as select column1 as a, arrow_cast(column2, 'Date64') as b from source;

query IDI
select a, b, count(*) from t group by a, b order by a, b;
----
1 2020-01-01T00:00:00 2
1 NULL 1
2 2020-01-02T00:00:00 3
2 2020-01-03T00:00:00 2
3 2020-01-04T00:00:00 2
NULL 2020-01-01T00:00:00 2
NULL NULL 2

statement ok
drop view t

statement ok
drop table source;

# Test multi group by int + Time32
statement ok
create table source as values
(1, '12:34:56'),
(1, '12:34:56'),
(2, '13:00:00'),
(2, '14:15:00'),
(3, '23:59:59'),
(3, '23:59:59'),
(2, '14:15:00'),
(null, null),
(null, '12:00:00'),
(null, null),
(null, '12:00:00'),
(2, '13:00:00'),
(2, '13:00:00'),
(1, null)
;

statement ok
create view t as select column1 as a, arrow_cast(column2, 'Time32(Second)') as b from source;

query IDI
select a, b, count(*) from t group by a, b order by a, b;
----
1 12:34:56 2
1 NULL 1
2 13:00:00 3
2 14:15:00 2
3 23:59:59 2
NULL 12:00:00 2
NULL NULL 2

statement ok
drop view t

statement ok
drop table source;

# Test multi group by int + Time64
statement ok
create table source as values
(1, '12:34:56.123456'),
(1, '12:34:56.123456'),
(2, '13:00:00.000001'),
(2, '14:15:00.999999'),
(3, '23:59:59.500000'),
(3, '23:59:59.500000'),
(2, '14:15:00.999999'),
(null, null),
(null, '12:00:00.000000'),
(null, null),
(null, '12:00:00.000000'),
(2, '13:00:00.000001'),
(2, '13:00:00.000001'),
(1, null)
;

statement ok
create view t as select column1 as a, arrow_cast(column2, 'Time64(Microsecond)') as b from source;

query IDI
select a, b, count(*) from t group by a, b order by a, b;
----
1 12:34:56.123456 2
1 NULL 1
2 13:00:00.000001 3
2 14:15:00.999999 2
3 23:59:59.500 2
NULL 12:00:00 2
NULL NULL 2

statement ok
drop view t

statement ok
drop table source;

# Test multi group by int + Timestamp
statement ok
create table source as values
(1, '2020-01-01 12:34:56'),
(1, '2020-01-01 12:34:56'),
(2, '2020-01-02 13:00:00'),
(2, '2020-01-03 14:15:00'),
(3, '2020-01-04 23:59:59'),
(3, '2020-01-04 23:59:59'),
(2, '2020-01-03 14:15:00'),
(null, null),
(null, '2020-01-01 12:00:00'),
(null, null),
(null, '2020-01-01 12:00:00'),
(2, '2020-01-02 13:00:00'),
(2, '2020-01-02 13:00:00'),
(1, null)
;

statement ok
create view t as select column1 as a, arrow_cast(column2, 'Timestamp(Nanosecond, None)') as b from source;

query IPI
select a, b, count(*) from t group by a, b order by a, b;
----
1 2020-01-01T12:34:56 2
1 NULL 1
2 2020-01-02T13:00:00 3
2 2020-01-03T14:15:00 2
3 2020-01-04T23:59:59 2
NULL 2020-01-01T12:00:00 2
NULL NULL 2

statement ok
drop view t

statement ok
drop table source;

0 comments on commit 42817e6

Please sign in to comment.