You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2a7a1e3
Browse filesBrowse the repository at this point in the historyBrowse files
fix(proto): check plan integer conversions across usize boundaries (apache#24483)
## Which issue does this PR close?
- Part of apache#24170.
## Rationale for this change
Several logical and physical plan protobuf paths convert wire integers
to `usize` with unchecked casts. On 32-bit targets, values above
`u32::MAX` silently truncate. For row limits, a fetch of `1 << 32`
becomes `0`, causing a plan that should return rows to return an empty
result.
The reverse conversion can also truncate when a 64-bit `usize` does not
fit the protobuf field.
## What changes are included in this PR?
- Add shared helpers for checked conversions between wire integers and
`usize`, with errors identifying the plan node and field.
- Apply checked conversions to limits, partition counts, batch sizes,
capacities, and indexes across logical and physical plan serialization.
- Preserve the documented `-1` sentinel for limits without a fetch.
- Reject invalid zero batch sizes while preserving proto3 defaults for
older `FilterExec` payloads.
- Treat out-of-range `usize` statistics as unknown rather than
truncating them.
The protobuf wire format is unchanged.
Follow-up work will make common protobuf option and constraint
conversions fallible.
## Are these changes tested?
Yes. Added unit and protobuf roundtrip coverage for checked conversions,
architecture-dependent integer boundaries, oversized encode/decode
values, limits without a fetch, malformed zero-column `Values` nodes,
and zero batch sizes.
## Are there any user-facing changes?
Out-of-range plan integers now return a clear planning error instead of
silently truncating. Invalid zero batch sizes are rejected, and
out-of-range statistics become unknown. There are no breaking public API
or protobuf wire-format changes.
0 commit comments