Skip to content

Commit d833b56

Browse files
committed
add tests
1 parent fb775bd commit d833b56

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

datafusion/sqllogictest/test_files/aggregate.slt

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4969,7 +4969,7 @@ select count(distinct column1), count(distinct column2) from dict_test group by
49694969
statement ok
49704970
drop table dict_test;
49714971

4972-
# avg_duartion
4972+
# avg_duration
49734973

49744974
statement ok
49754975
create table d as values
@@ -4998,6 +4998,50 @@ SELECT avg(column1), avg(column2), avg(column3), avg(column4), column5 FROM d GR
49984998
statement ok
49994999
drop table d;
50005000

5001+
statement ok
5002+
create table d as values
5003+
(arrow_cast(1, 'Duration(Second)'), arrow_cast(2, 'Duration(Millisecond)'), arrow_cast(3, 'Duration(Microsecond)'), arrow_cast(4, 'Duration(Nanosecond)'), 1),
5004+
(arrow_cast(11, 'Duration(Second)'), arrow_cast(22, 'Duration(Millisecond)'), arrow_cast(33, 'Duration(Microsecond)'), arrow_cast(44, 'Duration(Nanosecond)'), 1),
5005+
(arrow_cast(5, 'Duration(Second)'), arrow_cast(10, 'Duration(Millisecond)'), arrow_cast(15, 'Duration(Microsecond)'), arrow_cast(20, 'Duration(Nanosecond)'), 2),
5006+
(arrow_cast(25, 'Duration(Second)'), arrow_cast(50, 'Duration(Millisecond)'), arrow_cast(75, 'Duration(Microsecond)'), arrow_cast(100, 'Duration(Nanosecond)'), 2),
5007+
(NULL, NULL, NULL, NULL, 1),
5008+
(NULL, NULL, NULL, NULL, 2);
5009+
5010+
# verify NULL values are ignored in aggregation
5011+
query ????
5012+
SELECT avg(column1) FROM d;
5013+
----
5014+
0 days 0 hours 0 mins 10.5 secs
5015+
5016+
query ????I
5017+
SELECT column5, avg(column1) FROM d GROUP BY column5;
5018+
----
5019+
1 0 days 0 hours 0 mins 6 secs 2 0 days 0 hours 0 mins 15 secs
5020+
5021+
# window function tests for retract batch code
5022+
query ????I
5023+
SELECT column5, column1, avg(column1) OVER (PARTITION BY column5 ORDER BY column1 ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) as window_avg
5024+
FROM d WHERE column1 IS NOT NULL;
5025+
----
5026+
1 0 days 0 hours 0 mins 1 secs 0 days 0 hours 0 mins 1 secs 1 0 days 0 hours 0 mins 11 secs 0 days 0 hours 0 mins 6 secs2 0 days 0 hours 0 mins 5 secs 0 days 0 hours 0 mins 5 secs 2 0 days 0 hours 0 mins 25 secs 0 days 0 hours 0 mins 15 secs
5027+
5028+
# window function with cumulative frame
5029+
query ????I
5030+
SELECT column5, column1, avg(column1) OVER (ORDER BY column5, column1 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as cumulative_avg
5031+
FROM d WHERE column1 IS NOT NULL;
5032+
----
5033+
1 0 days 0 hours 0 mins 1 secs 0 days 0 hours 0 mins 1 secs 1 0 days 0 hours 0 mins 11 secs 0 days 0 hours 0 mins 6 secs 2 0 days 0 hours 0 mins 5 secs 0 days 0 hours 0 mins 5.666666667 secs 2 0 days 0 hours 0 mins 25 secs 0 days 0 hours 0 mins 10.5 secs
5034+
5035+
# window function with centered frame
5036+
query ????I
5037+
SELECT column5, column1, avg(column1) OVER (ORDER BY column5 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as centered_avg
5038+
FROM d WHERE column1 IS NOT NULL;
5039+
----
5040+
1 0 days 0 hours 0 mins 1 secs 0 days 0 hours 0 mins 6 secs 1 0 days 0 hours 0 mins 11 secs 0 days 0 hours 0 mins 8 secs 2 0 days 0 hours 0 mins 5 secs 0 days 0 hours 0 mins 13.66666667 secs 2 0 days 0 hours 0 mins 25 secs 0 days 0 hours 0 mins 15 secs
5041+
5042+
statement ok
5043+
drop table d;
5044+
50015045
# Prepare the table with dictionary values for testing
50025046
statement ok
50035047
CREATE TABLE value(x bigint) AS VALUES (1), (2), (3), (1), (3), (4), (5), (2);

0 commit comments

Comments
 (0)