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

Fix behaviour of quantileDeterministic function #25313

Merged
merged 3 commits into from
Jun 16, 2021

Conversation

alexey-milovidov
Copy link
Member

Changelog category (leave one):

  • Bug Fix

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix the possibility of non-deterministic behaviour of the quantileDeterministic function and similar. This closes #20480.

@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Jun 16, 2021
setSkipDegree(skip_degree + 1);

/// Still good?
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix.

In previous version, the value is not being filtered after coarsening, so one excessive value can appear in the final reservoir.

@@ -59,9 +59,10 @@ template <typename T,
ReservoirSamplerDeterministicOnEmpty OnEmpty = ReservoirSamplerDeterministicOnEmpty::THROW>
class ReservoirSamplerDeterministic
{
bool good(const UInt32 hash)
private:
Copy link
Member Author

@alexey-milovidov alexey-milovidov Jun 16, 2021

Choose a reason for hiding this comment

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

This is old code (circa 2014), it also contains hairy decisions and mistakes. E.g. total_values is calculated and serialized but not used.

@alexey-milovidov
Copy link
Member Author

Functional stateless tests flaky check (address) — fail: 66, passed: 234

This is fine.

@alexey-milovidov alexey-milovidov merged commit 0e16ddd into master Jun 16, 2021
@alexey-milovidov alexey-milovidov deleted the fix-quantile-determinism branch June 16, 2021 22:24
@alexey-milovidov alexey-milovidov self-assigned this Jun 16, 2021
alexey-milovidov added a commit that referenced this pull request Jun 17, 2021
Backport #25313 to 21.6: Fix behaviour of quantileDeterministic function
alexey-milovidov added a commit that referenced this pull request Jun 17, 2021
Backport #25313 to 21.3: Fix behaviour of quantileDeterministic function
alexey-milovidov added a commit that referenced this pull request Jun 17, 2021
Backport #25313 to 21.5: Fix behaviour of quantileDeterministic function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix Pull request with bugfix, not backported by default
Projects
None yet
Development

Successfully merging this pull request may close these issues.

quantileDeterministic and friends are not deterministic
2 participants