Skip to content

HIVE-29265: Columns failed stats computation still marked as COLUMN_STATS_ACCURATE#6576

Open
cyanzheng2926 wants to merge 3 commits into
apache:masterfrom
cyanzheng2926:HIVE-29265_stale_stats_marked_accurate
Open

HIVE-29265: Columns failed stats computation still marked as COLUMN_STATS_ACCURATE#6576
cyanzheng2926 wants to merge 3 commits into
apache:masterfrom
cyanzheng2926:HIVE-29265_stale_stats_marked_accurate

Conversation

@cyanzheng2926

Copy link
Copy Markdown
Contributor

/<!--
Thanks for sending a pull request! Here are some tips for you:

  1. If this is your first time, please read our contributor guidelines: https://cwiki.apache.org/confluence/display/Hive/HowToContribute
  2. Ensure that you have created an issue on the Hive project JIRA: https://issues.apache.org/jira/projects/HIVE/summary
  3. Ensure you have added or run the appropriate tests for your PR:
  4. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]HIVE-XXXXX: Your PR title ...'.
  5. Be sure to keep the PR description updated to reflect all changes.
  6. Please write your PR title to summarize what this PR proposes.
  7. If possible, provide a concise example to reproduce the issue for a faster review.

-->

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:

  • Non-native partitioned tables (e.g. Iceberg) only table-level cleanup is done, since currently there is no storage-handler API to clear partition-level COLUMN_STATS_ACCURATE.

  • Marker removal is using alterPartitions and alterTable with transactional=false, since these are parameter-only metadata updates, and the pre-existing setOrRemoveColumnStatsAccurateProperty success path is currently implemented in the same way.

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.
Before: After a partial or total column-stats failure, DESCRIBE FORMATTED

could show COLUMN_STATS_ACCURATE with "column":"true" even when COLUMN_STATS was missing for that column.

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

…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.
@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants