Fix MutableColumnStatisticsTest#18018
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes MutableColumnStatisticsTest to align with the current MutableColumnStatistics implementation, which computes variable-width element lengths via Dictionary#getValueSize().
Changes:
- Update the test to mock
Dictionary#getValueSize(int)instead ofgetStringValue(int). - Add Guava
Utf8usage for computing UTF-8 byte length in the mock answer.
| when(dictionary.getValueSize(anyInt())).thenAnswer( | ||
| invocation -> Utf8.encodedLength(elements[(int) invocation.getArgument(0)])); |
There was a problem hiding this comment.
The mocked dictionary.getValueSize() uses Utf8.encodedLength(...), but the expected minElementLength/maxElementLength are computed with randomString.getBytes(UTF_8).length. These can diverge (and Utf8.encodedLength can throw for malformed surrogate pairs), making the test potentially flaky. Consider computing expected lengths using the same Utf8.encodedLength(...) logic (or restrict generated strings to ASCII/alphanumeric) so the test matches the production StringDictionary#getValueSize behavior.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18018 +/- ##
============================================
+ Coverage 55.53% 63.29% +7.75%
- Complexity 752 1543 +791
============================================
Files 2505 3200 +695
Lines 143118 194169 +51051
Branches 22967 29915 +6948
============================================
+ Hits 79481 122899 +43418
- Misses 56897 61611 +4714
- Partials 6740 9659 +2919
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.