Repository navigation
fix: treat numRows zero as unlimited - #1159
Conversation
Signed-off-by: liuhy <liuhongyu@apache.org>
|
Small suggestion from a fellow traveler on #1149 (my overlapping #1189 — closing it in favor of this one, the core guard is identical). While testing I also covered two neighboring cases that might be worth guarding here: |
BigDataDZ
left a comment
There was a problem hiding this comment.
The core guard is exactly right - limit > 0 matches the documented sentinel, and it is the same shape I had shipped in the closed #1189 (verified there against 9 format/level combinations).
Two of the neighboring cases from the Oct-9 comment are still uncovered, and they protect the other half of the condition:
- A positive limit must still stop the read -
limit > 0exists to disable the zero sentinel, but nothing pins that a legitimatenumRows(1)still truncates. Without that case, a future "simplification" tolimit == null || limit <= 0 || index < limit-style refactors could silently read everything. - Omitted numRows stays unlimited - the
limit == nullfall-through from sheet holder to workbook holder.
One testing detail from #1189 that will save you an iteration on case 1: lastRowIndex counts the head row (a headed file's first data row sits at index 1), so numRows(1) on a headed default read delivers zero data rows. Writing a header-less file (or headRowNumber(0)) makes the limit map one-to-one onto data rows - my closed branch has ready-made parameterized tests for all three cases (zero / omitted / positive across XLSX, XLS, CSV) if you want to lift them: BigDataDZ/fesod@f4e0ec7 (NumRowsReadLimitTest).
Happy to review the follow-up commit. Otherwise LGTM on the fix itself.
Closed: #1149
Summary
Verification