HIVE-29265: Columns failed stats computation still marked as COLUMN_STATS_ACCURATE#6576
Open
cyanzheng2926 wants to merge 5 commits into
Open
HIVE-29265: Columns failed stats computation still marked as COLUMN_STATS_ACCURATE#6576cyanzheng2926 wants to merge 5 commits into
cyanzheng2926 wants to merge 5 commits into
Conversation
…ats collection fails When column stats collection is skipped (e.g. UnsupportedDoubleException for Inf/NaN in float/double min/max stats), failed columns were still makred as true in COLUMN_STATS_ACCURATE even though stats are not present. Track per-table/partition column failures in ColStatsProcessor and remove incorrect accurate markers via alterTable and alterPartitions.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a correctness bug in Hive column statistics collection where columns that fail stats gathering (when hive.stats.reliable=false) could remain marked as accurate in COLUMN_STATS_ACCURATE, causing the optimizer to treat missing/invalid stats as usable.
Changes:
- Track per-column stats-collection failures during
ColStatsProcessorexecution and remove staleCOLUMN_STATS_ACCURATEmarkers for failed columns (table-level and native HMS partitions). - Add a new qtest (
stats_col_stats_inaccurate.q) and golden output validatingCOLUMN_STATS_ACCURATEcleanup for Infinity/NaN-induced failures. - Update existing qtest output (
columnstats_infinity.q.out) to reflect the correctedCOLUMN_STATS_ACCURATEcontents.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ql/src/java/org/apache/hadoop/hive/ql/stats/ColStatsProcessor.java | Tracks failed columns and clears stale COLUMN_STATS_ACCURATE markers (table/partition where supported). |
| ql/src/test/queries/clientpositive/stats_col_stats_inaccurate.q | New test query covering partial/total column-stats failures across partitioned/non-partitioned tables. |
| ql/src/test/results/clientpositive/llap/stats_col_stats_inaccurate.q.out | New golden output validating corrected DESCRIBE FORMATTED/COLUMN_STATS_ACCURATE behavior. |
| ql/src/test/results/clientpositive/llap/columnstats_infinity.q.out | Adjust golden output to match corrected COLUMN_STATS_ACCURATE after failure cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| describe formatted stats_t1 partition(p=1); | ||
|
|
||
|
|
||
| -- Check non-partitioned tables on flout/double columns with Infinity/NaN on inaccurate stats. |
Comment on lines
+247
to
+251
| if (tbl.isNonNative() && tbl.getStorageHandler().canSetColStatistics(tbl)) { | ||
| if (!(tbl.isMaterializedView() || tbl.isView() || tbl.isTemporary())) { | ||
| setOrRemoveColumnStatsAccurateProperty(db, tbl, failedColumns, false); | ||
| } | ||
| } else { |
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.



/<!--
Thanks for sending a pull request! Here are some tips for you:
-->
What changes were proposed in this pull request?
When stats collection is skipped for some columns with hive.stats.reliable=false, no stats are written to the metastore, but COLUMN_STATS_ACCURATE still remains "true" for these columns.
Updated ColStatsProcessor to track for columns that failed stats gathering due to such errors, and remove the stale accurate markers for these columns.
Note on limitations:
Why are the changes needed?
Column stats collection can fail for individual columns (e.g. UnsupportedDoubleException with Infinity/NaN). With hive.stats.reliable=false the failure is logged and skipped, but still leaves COLUMN_STATS_ACCURATE claiming those columns are accurate even though no stats were stored. The optimizer may use non-existent stats and produce suboptimal or incorrect plans as a result.
Does this PR introduce any user-facing change?
Yes.
could show COLUMN_STATS_ACCURATE with "column":"true" even when COLUMN_STATS was missing for that column.Before: After a partial or total column-stats failure, DESCRIBE FORMATTED
After: Failed columns are removed from COLUMN_STATS_ACCURATE. Only columns with successfully collected stats remain marked accurate.
How was this patch tested?
Added qtest: stats_col_stats_inaccurate.q and corresponding golden, test for multiple cases when certain columns of partitioned/non-partitioned tables fail at stats gathering with Infinity/NaN, and desc formatted output should not return COLUMN_STATS_ACCURATE markers for these columns