-
-
Notifications
You must be signed in to change notification settings - Fork 19.6k
BUG: Fix JsonReader to handle nrows more robustly #64025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
rhshadrach
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
| # If self.chunksize, we prepare the data for the `__next__` method. | ||
| # Otherwise, we read it into memory for the `read` method. | ||
| if not (self.chunksize or self.nrows): | ||
| if self.chunksize is None and self.nrows is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we validate that if these are not None, then nrows is nonnegative and chunksize is positive?
| if self.nrows is not None and self.nrows_seen >= self.nrows: | ||
| self.close() | ||
| raise StopIteration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this block can just be removed
| - Fixed :func:`read_json` with ``lines=True`` and ``chunksize`` to respect ``nrows`` | ||
| when the requested row count is not a multiple of the chunk size. | ||
| - Fixed :func:`read_json` with ``lines=True`` and ``nrows=0`` returning all rows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the note to 3.1.0 since this is not a regression.
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.AGENTS.md.This PR fixes inconsistent behavior of
JsonReaderwithlines=True, whenchunksizedoes not dividenrowsor whennrows=0. This can be illustrated by the following two snippets: