Skip to content

fix: treat numRows(0) as no row limit when reading (#1149) - #1189

Closed
BigDataDZ wants to merge 1 commit into
apache:mainfrom
BigDataDZ:fix/numrows-zero-unlimited
Closed

BigDataDZ wants to merge 1 commit into
apache:mainfrom
BigDataDZ:fix/numrows-zero-unlimited

Conversation

@BigDataDZ

Copy link
Copy Markdown
Contributor

What changed

The default ReadListener#hasNext now applies the numRows limit only when it is positive. Zero — documented as "no limit on the number of rows, i.e. read all rows" — previously stopped the read before the first row.

Why

no numRows setting: 3 rows
numRows(0):          0 rows   # was stopped immediately
numRows(1):          1 row

The row index starts at the head row, so a zero limit failed index >= limit for every row including the first one.

Fixes #1149

How tested

New NumRowsReadLimitTest, parameterized over XLSX / XLS / CSV via @ExcelFormatSource on headless workbooks (so the limit maps one-to-one onto data rows):

  • numRows(0) reads all rows, same as omitting the setting
  • a positive limit (numRows(1)) still stops the read early

Full fesod-sheet suite passes locally on Temurin 25; spotless:check clean.

The default ReadListener#hasNext applied any non-null limit, so
numRows(0) stopped the read before the first row. The documentation
defines zero as "no limit on the number of rows, i.e. read all rows".

Only apply the limit when it is positive, and add a parameterized
regression test over all supported read formats covering the zero
sentinel, the omitted setting and a positive limit that still stops
early.

Closes apache#1149
@BigDataDZ

Copy link
Copy Markdown
Contributor Author

Closing in favor of #1159 — the core change is identical (only a positive limit should stop the read). I left a suggestion there to also guard the omitted-numRows and positive-limit cases.

@BigDataDZ BigDataDZ closed this Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] numRows(0) stops reading instead of disabling the row limit

2 participants