Skip to content

Parquet: Fix notNaN for columns missing from files - #17633

Merged
RussellSpitzer merged 1 commit into
apache:mainfrom
yangshangqing95:fix/parquet-notnan-missing-column-npe
Aug 13, 2026
Merged

Parquet: Fix notNaN for columns missing from files#17633
RussellSpitzer merged 1 commit into
apache:mainfrom
yangshangqing95:fix/parquet-notnan-missing-column-npe

Conversation

@yangshangqing95

Copy link
Copy Markdown
Contributor

Fix #17632

Fix an NPE when a notNaN predicate references a column that has an initial default but is absent from an older Parquet file.

Treat missing null metadata conservatively and add regression coverage for columns absent from Parquet files.

int id = ref.fieldId();

if (mayContainNulls.get(id)) {
if (mayContainNulls.get(id) == null || mayContainNulls.get(id)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should match the pattern in the other checks and just relocate if (mayContainNulls) to under the "hasNonDictPages"

The reason being the "isFallback.get(id) " would essentially be doing the "is this column there" check for us.

@Override
public <T> Boolean notNaN(BoundReference<T> ref) {
  int id = ref.fieldId();

  Boolean hasNonDictPage = isFallback.get(id);
  if (hasNonDictPage == null || hasNonDictPage) {
    return ROWS_MIGHT_MATCH;
  }

  if (mayContainNulls.get(id)) {
    return ROWS_MIGHT_MATCH;
  }

  Set<T> dictionary = dict(id, comparatorForNaNPredicate(ref));
  return dictionary.stream().allMatch(NaNUtil::isNaN) ? ROWS_CANNOT_MATCH : ROWS_MIGHT_MATCH;
}

This is basically the same as all the others

public <T> Boolean isNaN(BoundReference<T> ref) {
  int id = ref.fieldId();
  
Boolean hasNonDictPage = isFallback.get(id);
  if (hasNonDictPage == null || hasNonDictPage) {
    return ROWS_MIGHT_MATCH;
  }
  
Set<T> dictionary = dict(id, comparatorForNaNPredicate(ref));
  return dictionary.stream().anyMatch(NaNUtil::isNaN) ? ROWS_MIGHT_MATCH : ROWS_CANNOT_MATCH;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, done.

notNull("not_in_file"),
isNull("not_in_file"),
notEqual("not_in_file", 1.0f),
notNaN("not_in_file")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on Tests, Thanks for covering these!

@yangshangqing95
yangshangqing95 force-pushed the fix/parquet-notnan-missing-column-npe branch from b0a29c4 to d85205e Compare August 13, 2026 19:08
@RussellSpitzer
RussellSpitzer merged commit 7e56d30 into apache:main Aug 13, 2026
37 checks passed
@RussellSpitzer

Copy link
Copy Markdown
Member

Thanks @yangshangqing95 !

@yangshangqing95

Copy link
Copy Markdown
Contributor Author

Thanks @RussellSpitzer for reviewing!

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.

Parquet: notNaN filter throws NPE for columns missing from files

2 participants