HIVE-29516 Fix NPE in StatsUtils.updateStats when column statistics a…#6382
Open
shubhluck wants to merge 1 commit intoapache:masterfrom
Open
HIVE-29516 Fix NPE in StatsUtils.updateStats when column statistics a…#6382shubhluck wants to merge 1 commit intoapache:masterfrom
shubhluck wants to merge 1 commit intoapache:masterfrom
Conversation
…re unavailable Added null checks before iterating over column statistics in: - StatsUtils.updateStats() - StatsUtils.getColStatisticsUpdatingTableAlias() - StatsRulesProcFactory (JOIN statistics) This prevents query compilation failures during semijoin optimization when column-level statistics are incomplete, commonly seen with large TPC-DS datasets (100GB+).
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



…re unavailable
Added null checks before iterating over column statistics in:
What changes were proposed in this pull request?
This PR adds null checks before iterating over column statistics in three locations to prevent NullPointerException:
stats.getColumnStats()before the for-each loop, defaulting to empty list when nullThe root cause is that
Statistics.getColumnStats()returnsnull(not an empty list) when no column statistics are available:Why are the changes needed?
Query compilation fails with NullPointerException during semijoin optimization when column statistics are unavailable:
This issue is particularly prevalent with:
Large TPC-DS datasets (100GB+) where statistics collection may be incomplete
Tables where column-level statistics have not been computed
Complex queries where intermediate operators lack column statistics
The fix ensures graceful handling when column statistics are unavailable, allowing the optimizer to continue using row-based statistics instead of failing.
Does this PR introduce any user-facing change?
No. This is a bug fix that prevents query compilation failures. Previously failing queries will now compile and execute successfully. There is no change to query results or behavior for queries that were already working.
How was this patch tested?
To reproduce the original issue: