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

Make Topk aggregate tests deterministic #8998

merged 2 commits into from
Jan 26, 2024

Conversation

mustafasrepo
Copy link
Contributor

Which issue does this PR close?

Closes #8845.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@mustafasrepo mustafasrepo changed the title Make tests deterministic Make Topk aggregate tests deterministic Jan 25, 2024
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Jan 25, 2024
Copy link
Contributor

@avantgardnerio avantgardnerio left a comment

Choose a reason for hiding this comment

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

It doesn't test the code path with collisions anymore, but that might be okay @alamb

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

Thanks @mustafasrepo but just for curiosity, how the test becomes deterministic if only test result has changed? 🤔 no extra sorting or code change

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

I think this PR makes a lot of sense to me -- thank you @mustafasrepo . I am pretty sure it still covers the core use case -- I left a comment that might also increase coverage.

@avantgardnerio if you have additional suggestions on how to improve this test that would be most helpful

@@ -26,8 +26,8 @@ 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),

@mustafasrepo
Copy link
Contributor Author

mustafasrepo commented Jan 26, 2024

Thanks @mustafasrepo but just for curiosity, how the test becomes deterministic if only test result has changed? 🤔 no extra sorting or code change

In this PR, I have changed source table such that timestamp values are unique. Since each group consists of distinct rows, MIN(timestamp), or MAX(timestamp) would produce unique results after aggregation (e.g different for each row). Hence when ordering ORDER BY MIN(timestamp) is applied there is no tie break (in tie break there will be more than 1 true result, and results may change when some implementation change seemingly unrelated).

@mustafasrepo mustafasrepo merged commit bee7136 into apache:main Jan 26, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure in sqllogictest aggregates_topk.slt on mac
4 participants