GH-30894: [C++][Python] Fix Table::Slice returning incorrect length f…#50369
Open
AdvancedUno wants to merge 2 commits into
Open
GH-30894: [C++][Python] Fix Table::Slice returning incorrect length f…#50369AdvancedUno wants to merge 2 commits into
AdvancedUno wants to merge 2 commits into
Conversation
…ngth for tables with no columns
|
|
1 similar comment
|
|
Member
|
Thanks for the PR @AdvancedUno! The linter is failing - you can find instructions here on running the linter, but let me know if you have any issues! |
Author
|
Hi @thisisnic, I just made the fix! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Table::Sliceon a table with no columns does not adjust the row count.SimpleTable::Slicecomputesnum_rowsinside the per-column loop, so with zero columns the loop never runs andnum_rowskeeps the rawlengthargument instead of being clamped to the rows actually available.This violates the contract documented in table.h: "If there are not enough rows in the table, the length will be adjusted accordingly."
What changes are included in this PR?
Are these changes tested?
Yes. The new C++ and Python regression tests cover slicing a zero-column table with offset only, offset + length, an offset past the end , and consistency with a table whose columns were all removed using SelectColumns({}).
Are there any user-facing changes?
Yes. Table.slice() on a table with no columns now returns the correct num_rows instead of echoing back the raw length argument. This is a bug fix, there are no API changes.
Closes #30894