Skip to content

fix: guard against Parquet getNumNulls returning -1 for missing null count - #17559

Open
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/null-count-getnumnulls-minus-1
Open

fix: guard against Parquet getNumNulls returning -1 for missing null count#17559
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/null-count-getnumnulls-minus-1

Conversation

@waterWang

Copy link
Copy Markdown

Fixes #17558

Parquet's Statistics#getNumNulls returns -1 when null_count is missing from the column chunk statistics. The current code unconditionally adds -1 to the accumulated null count, which produces incorrect results when multiple row groups are merged across a column chunk.

For example, with row group 0 having 1 null and row group 1 missing null_count (returning -1), the total becomes 0 instead of at least 1. A query engine relying on null count could skip the file entirely when evaluating predicates like WHERE c IS NULL, causing wrong results.

This fix wraps all getNumNulls() calls with Math.max(..., 0) to safely handle the missing null_count case across all four code paths: counts(), bounds(), and the two variant metric methods.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core, Parquet: Incorrect null counting when null_count is missing from Parquet stats

1 participant