Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Topk aggregate tests deterministic #8998

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions datafusion/sqllogictest/test_files/aggregates_topk.slt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ CREATE TABLE traces(trace_id varchar, timestamp bigint, other bigint) AS VALUES
('a', NULL, NULL),
('a', 1, 1),
('a', -1, -1),
('b', 0, 0),
('c', 1, 1),
('b', -2, 0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add some rows with a duplicate timestamp to address @avantgardnerio 's comment?

Perhaps something lke

('c', 4, 10),
('c', 2, 10),

('c', 4, 1),
('c', 4, 2),
('c', 2, 2),
('c', 2, 4),
('b', 3, 3);

statement ok
Expand Down Expand Up @@ -57,34 +59,34 @@ GlobalLimitExec: skip=0, fetch=4
query TI
select trace_id, MAX(timestamp) from traces group by trace_id order by MAX(timestamp) desc limit 4;
----
c 4
b 3
c 2
a 1
NULL 0

query TI
select trace_id, MIN(timestamp) from traces group by trace_id order by MIN(timestamp) asc limit 4;
----
b -2
a -1
NULL 0
b 0
c 1
c 2

query TII
select trace_id, other, MIN(timestamp) from traces group by trace_id, other order by MIN(timestamp) asc limit 4;
----
b 0 -2
a -1 -1
b 0 0
NULL 0 0
c 1 1
a 1 1

query TII
select trace_id, MIN(other), MIN(timestamp) from traces group by trace_id order by MIN(timestamp), MIN(other) limit 4;
----
b 0 -2
a -1 -1
NULL 0 0
b 0 0
c 1 1
c 1 2

statement ok
set datafusion.optimizer.enable_topk_aggregation = true;
Expand Down Expand Up @@ -168,45 +170,45 @@ GlobalLimitExec: skip=0, fetch=4
query TI
select trace_id, MAX(timestamp) from traces group by trace_id order by MAX(timestamp) desc limit 4;
----
c 4
b 3
c 2
a 1
NULL 0

query TI
select trace_id, MIN(timestamp) from traces group by trace_id order by MIN(timestamp) asc limit 4;
----
b -2
a -1
NULL 0
b 0
c 1
c 2

query TI
select trace_id, MAX(timestamp) from traces group by trace_id order by MAX(timestamp) desc limit 3;
----
c 4
b 3
c 2
a 1

query TI
select trace_id, MIN(timestamp) from traces group by trace_id order by MIN(timestamp) asc limit 3;
----
b -2
a -1
NULL 0
b 0

query TII
select trace_id, other, MIN(timestamp) from traces group by trace_id, other order by MIN(timestamp) asc limit 4;
----
b 0 -2
a -1 -1
b 0 0
NULL 0 0
c 1 1
a 1 1

query TII
select trace_id, MIN(other), MIN(timestamp) from traces group by trace_id order by MIN(timestamp), MIN(other) limit 4;
----
b 0 -2
a -1 -1
NULL 0 0
b 0 0
c 1 1
c 1 2
Loading