Skip to content

fix: clear partition-column extrema for empty files - #15

Draft
edmondop wants to merge 1 commit into
mainfrom
fix-empty-partition-statistics
Draft

edmondop wants to merge 1 commit into
mainfrom
fix-empty-partition-statistics

Conversation

@edmondop

Copy link
Copy Markdown
Owner

Which issue does this PR close?

Closes apache#27456.

Rationale for this change

A partitioned Parquet table with one row in p=1 and empty files in p=0 and p=7 returns 1, 0, 7 for SELECT count(*), min(p), max(p). The empty files contribute their directory values to the statistics used to answer MIN/MAX. The correct result is 1, 1, 1.

What changes are included in this PR?

PartitionedFile::with_statistics now gives partition columns absent MIN/MAX and zero distinct values when the file has exactly zero rows. It reuses is_known_empty, which distinguishes an exact zero from an estimate. The statistics contract is documented alongside the method and struct.

Absent combined extrema can require normal aggregate evaluation rather than answering MIN/MAX from metadata.

What is the testing strategy for this PR?

  • SQL regression in parquet_statistics.slt covers empty partitions below and above a nonempty partition, plus an empty selection. The mixed-partition query fails on upstream main with 1, 0, 7 and passes with this fix.
  • Unit tests cover empty files with null and non-null partition values, and unknown or inexact-zero row counts.
  • Extended workspace suite: 13,451 Rust tests passed, eight ignored; all 307 SQL logic files passed.
  • Both workspace Clippy feature sets, formatting, and the repository lint checks passed. The audit reports four allowed dependency warnings. On NixOS, the HTML documentation build was invoked with explicit bash because /bin/bash is absent.

Are there any user-facing changes?

MIN/MAX of partition columns no longer includes values from files known to contain zero rows.

Implemented and tested with AI assistance (Codex). This draft is awaiting author review.

@edmondop
edmondop force-pushed the fix-empty-partition-statistics branch from ff25057 to 7b81e40 Compare November 22, 2026 14:50
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.

MIN/MAX of a partition column includes partitions whose files have 0 rows

1 participant