Skip to content

Fix strict evaluation for negative record counts - #3831

Merged
kevinjqliu merged 1 commit into
apache:mainfrom
kevinjqliu:kevinjqliu/codex-fix-negative-record-count
Aug 23, 2026
Merged

Fix strict evaluation for negative record counts#3831
kevinjqliu merged 1 commit into
apache:mainfrom
kevinjqliu:kevinjqliu/codex-fix-negative-record-count

Conversation

@kevinjqliu

Copy link
Copy Markdown
Contributor

Summary

  • Treat record_count == 0 as empty in strict metrics evaluation.
  • Treat negative legacy/unknown counts conservatively as ROWS_MIGHT_NOT_MATCH.
  • Update the record-count short-circuit regression test.

This prevents strict evaluation from classifying files with unknown counts as fully matching, which can incorrectly authorize whole-file deletion.

Java validates newly built files with recordCount >= 0 (DataFiles.java), while manifest reads instantiate through Avro (GenericDataFile.java). Its inclusive evaluator handles negative counts as unknown (InclusiveMetricsEvaluator.java); the strict evaluator still groups them with empty files (StrictMetricsEvaluator.java).

Related to #3498.

Tests

  • uv run pytest tests/expressions/test_evaluator.py -q

Copilot AI lite review requested due to automatic review settings August 22, 2026 16:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes strict metrics evaluation for negative record counts, preventing unsafe whole-file deletion decisions.

Changes:

  • Treat zero-record files as empty.
  • Treat negative counts conservatively as potentially matching rows.
  • Update regression coverage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/expressions/test_evaluator.py Verifies conservative handling of negative counts.
pyiceberg/expressions/visitors.py Corrects strict record-count handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@kevinjqliu
kevinjqliu merged commit 6d814ed into apache:main Aug 23, 2026
18 checks passed
@kevinjqliu
kevinjqliu deleted the kevinjqliu/codex-fix-negative-record-count branch August 23, 2026 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants