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
HIVE-26277: Add unit tests for ColumnStatsAggregator classes #3339
HIVE-26277: Add unit tests for ColumnStatsAggregator classes #3339
Conversation
24e2033
to
ca684fc
Compare
Hey @asolimando If the bugs can appear in production I would suggest to create a new JIRA describing the problem or re-purpose this one. It is more important to know that a commit is fixing a bug rather than adding tests. |
You are right @zabetak, I'd then rename the Jira ticket as
WDYT? |
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.
@asolimando Thanks a lot for investing so much time in testing; definitely needed!
I didn't go over all the changes in the PR but I left some comments here and there (most of them rather minor) which could reduce the code size and make it more readable. I left the comments in specific places but I think they apply in more than one place.
Let's discuss on them to see if it makes sense to incorporate them in the PR before I do a complete pass.
...ore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/StatisticsTestUtils.java
Outdated
Show resolved
Hide resolved
...ore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/StatisticsTestUtils.java
Outdated
Show resolved
Hide resolved
...st/java/org/apache/hadoop/hive/metastore/columnstats/aggr/LongColumnStatsAggregatorTest.java
Outdated
Show resolved
Hide resolved
...st/java/org/apache/hadoop/hive/metastore/columnstats/aggr/LongColumnStatsAggregatorTest.java
Outdated
Show resolved
Hide resolved
...ore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/StatisticsTestUtils.java
Outdated
Show resolved
Hide resolved
...ore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/StatisticsTestUtils.java
Outdated
Show resolved
Hide resolved
...ore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/StatisticsTestUtils.java
Outdated
Show resolved
Hide resolved
...st/java/org/apache/hadoop/hive/metastore/columnstats/aggr/LongColumnStatsAggregatorTest.java
Outdated
Show resolved
Hide resolved
...st/java/org/apache/hadoop/hive/metastore/columnstats/aggr/LongColumnStatsAggregatorTest.java
Outdated
Show resolved
Hide resolved
...st/java/org/apache/hadoop/hive/metastore/columnstats/aggr/LongColumnStatsAggregatorTest.java
Outdated
Show resolved
Hide resolved
...st/java/org/apache/hadoop/hive/metastore/columnstats/aggr/LongColumnStatsAggregatorTest.java
Show resolved
Hide resolved
…ll rely on a non-empty list
e2fcd42
to
be7f2c5
Compare
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.
Hey @asolimando, I pushed a few small changes to your branch:
Let me know what you think of those, and from my side the change is good to go once tests come back green.
Kudos, SonarCloud Quality Gate passed! |
Thanks @zabetak, your commits LGTM and are improving the contribution! |
… (Alessandro Solimando reviewed by Stamatis Zampetakis) 1. Add and invoke checkStatisticsList to prevent NPEs in aggregators; they all rely on a non-empty list of statistics. 2. Cast integers to double in divisions to make computations more accurate and avoid rounding issues. 3. Align loggers names to match the class they are in and avoid misleading log messages. 4. Add documentation for ndvtuner based on current understanding of how it should work. Closes apache#3339 Move (and complete) ndvTuner documentation from tests to production classes
… (Alessandro Solimando reviewed by Stamatis Zampetakis) 1. Add and invoke checkStatisticsList to prevent NPEs in aggregators; they all rely on a non-empty list of statistics. 2. Cast integers to double in divisions to make computations more accurate and avoid rounding issues. 3. Align loggers names to match the class they are in and avoid misleading log messages. 4. Add documentation for ndvtuner based on current understanding of how it should work. Closes apache#3339 Move (and complete) ndvTuner documentation from tests to production classes
What changes were proposed in this pull request?
Adding unit tests for *ColumnStatsAggregator classes (first commit), fixing bugs discovered while writing the UTs (second commit) and guarding against invoking the methods with an empty list of statistics (which leads to NPEs).
Why are the changes needed?
Lack of unit tests is detrimental for code quality, as highlighted by the bugs discovered while writing the tests.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
mvn test -Dtest.groups=org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest -Dtest='*ColumnStatsAggregatorTest.java' -pl standalone-metastore/metastore-server