Validate requested rows before calling Arrow Dataset.head(-1)
Do not import pandas negative-head semantics into a different scanning API.
Matching names do not imply matching negative arguments
Validate the requested range before execution because APIs with the same name can assign different meanings to negative values. A preview service accepting user input needs the called API's range contract before invoking its reader. Checking a resulting Table afterward cannot prevent construction of an invalid state. [1, 2, 3]
A Table with negative length
The PyArrow 26.0.0 reproduction describes Dataset.head(-1) creating a Table with negative num_rows, followed by validation and len errors. The report distinguishes pandas-style exclusion of trailing rows from a scan length. It provides the R binding's early rejection as a control, rather than establishing the current behavior of every binding. [1]
Reject invalid requests before execution
Restrict preview requests to non-negative row counts. If trailing-row exclusion is required, expose an explicit operation based on total length. Record request_id and api_family. Validate integer representation separately from the lower bound, and do not silently take an absolute value that changes the user's request. [1, 3]
Boundary zero and counterexample minus one
The illustrative contract accepts integer requested_rows values of at least 0. 0 passes as an empty preview; -1 fails. Truthound Core's BetweenValidator can apply lower bound 0 to the numeric field of a separate request-settings table before native scanning. It checks configuration values, not repair of an already-invalid Arrow Table. [1, 2, 3]
Application conditions
Prepare request_id, requested_rows and api_family from the original request or an independent control, aligned to the same run, file and key scope.
Alternatives
Reject negative requests and offer a separate API based on the total length.
Limitations
This does not mean Truthound can repair an invalid Arrow Table. The checked input is a separate table of request settings.
Evidence
- Event checked
- Subject checked
- Modified
