Skip to content

GH-55886: [C++][Dataset] Preserve narrowing casts during Parquet pruning - #55941

Open
TatvagnaTandel wants to merge 1 commit into
apache:mainfrom
TatvagnaTandel:fix/parquet-narrowing-cast-55886
Open

TatvagnaTandel wants to merge 1 commit into
apache:mainfrom
TatvagnaTandel:fix/parquet-narrowing-cast-55886

Conversation

@TatvagnaTandel

Copy link
Copy Markdown

Rationale for this change

Arrow uses Parquet row group statistics to skip groups that cannot match a filter. Those statistics describe the original float64 column. When a filter casts that column to float32, rounding can move a value onto the comparison boundary.

In the reported case, 17.799999999999997 is greater than the threshold 17.799999237060547 before casting. After casting to float32, it equals the threshold and should satisfy the <= comparison. The simplifier stripped the cast, so pruning compared the original float64 bound against the threshold and skipped a row group that contained a match. The same problem affected >= comparisons.

What changes are included in this PR?

The expression simplifier retains narrowing floating point casts and still simplifies widening casts. When a widening cast wraps a narrowing cast, the simplifier can remove the outer cast while preserving the inner one. The patch leaves integer to floating point handling unchanged.

Are these changes tested?

  • Added Parquet regressions for both <= and >=. Each scan returned zero rows before the fix and the expected matching row afterward.
  • Added expression coverage for widening, narrowing, and a narrowing cast nested inside a widening cast.
  • All 12 native CTest suites passed before the push.

Are there any user-facing changes?

Affected Parquet Dataset filters now return matching rows that were previously skipped.

Critical Fix: The bug produced incomplete query results by dropping matching rows during pruning. The patch changes no public APIs.

Was AI used for this PR?

Codex generated the implementation and documentation.

I personally reviewed the implementation and test.

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.

[Python][C++][Dataset] Parquet row groups are skipped for comparisons on cast(x, float32) when x is float64

1 participant