-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix flaky TestPositionsAppender.testConsecutiveBuilds #12888
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 flaky TestPositionsAppender.testConsecutiveBuilds #12888
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the variable named positionCount ? For map and array isn't offsets[positionCount] the total length of data in the Block ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For map and array isn't offsets[positionCount] the total length of data in the Block ?
well yes, if by total length you mean position count of the data/value block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you call it entryCount or valuesLength ? At least that's the terminology used in AbstractArrayBlock or AbstractMapBlock to distinguish it from positionCount.
Also consider passing down offsets and positionCount separately to this method if it's always meant to be used in context of Map and Row
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is not specific to AbstractMapBlock or AbstractArrayBlock. It returns the nullRate that will match exactly the number of null positions for the given position count.
|
Why can't we just fix |
It accepts 0 nulls already. it fails if the null rate is not 0 but the result would be empty. This is to guard against unintentional setup where non-zero |
With |
Yes, but only in the nested type case for the value block. |
Maybe a separate method without that check? |
do we need two? how would use this new method given there is a recursive call in |
I think it's cleaner than adding a method with check and then creating another method that mitigates that check. You already have two methods |
there is a recursive call in createRandomBlockForNestedType |
Would it be possible to simply exclude test cases that generate 0 nulls? |
0c0df8b to
de5f9d9
Compare
Use fresh Random instance per method to make the test deterministic
de5f9d9 to
36f4446
Compare
after offline discussion I changed this fix to make the |
|
|
||
| int[] ids = IntStream.range(0, positionCount) | ||
| .map(i -> RANDOM.nextInt(dictionary.getPositionCount())) | ||
| .map(i -> random().nextInt(dictionary.getPositionCount())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Um, this actually uses a fresh Random instance per iteration. Each instance has the same seed, so each iteration will produce the same result. So this is kind of more deterministic than you wanted, I think :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Since for nested types createRandomBlockForNestedType
chooses the lengths of the nested values randomly,
there is a chance that the chosen value length is
not big enough for the given nullRate.
To fix this, we cap the nested values nullRate, possibly to 0,
so it matches the nested position count.
fix flaky test
core query engine tests
fix flaky test
Related issues, pull requests, and links
Documentation
( ) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
( ) Release notes entries required with the following suggested text:
Fixes #12888