Skip to content

[data] Clarify Dataset.sort key documentation - #66926

Closed
viiccwen wants to merge 2 commits into
ray-project:masterfrom
viiccwen:docs/fix-ray-data-sort-doc-mismatch
Closed

viiccwen wants to merge 2 commits into
ray-project:masterfrom
viiccwen:docs/fix-ray-data-sort-doc-mismatch

Conversation

@viiccwen

Copy link
Copy Markdown
Contributor

Description

Clarifies the Dataset.sort() docstring to state that sorting is performed by the specified one or more key columns.

This aligns the public documentation with the supported key: Union[str, List[str]] API and avoids implying that a callable key function is accepted.

Related issues

Link related issues: "Fixes #1234", "Closes #1234", or "Related to #1234".

Additional information

Optional: Add implementation details, API changes, usage examples, screenshots, etc.

@viiccwen
viiccwen requested a review from a team as a code owner October 12, 2026 02:34

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the docstring of the sort method in python/ray/data/dataset.py to clarify that the dataset is sorted by one or more key columns instead of a key column or key function. There are no review comments, and I have no feedback to provide.

@ray-gardener ray-gardener Bot added data Ray Data-related issues community-contribution Contributed by the community labels Oct 12, 2026
@viiccwen

Copy link
Copy Markdown
Contributor Author

Consolidated into #66927 per review feedback that these changes are too small to land separately.

@viiccwen viiccwen closed this Oct 23, 2026
owenowenisme added a commit that referenced this pull request Nov 14, 2026
#66927)

## Description

Fixes two Ray Data docstrings that don't match how the code actually
behaves, and adds a test for the behavior the corrected docstring
describes.

- **`read_json(lines=True)`**: the docstring said `filesystem`,
`arrow_open_stream_args`, and `arrow_json_args` are *ignored* in this
mode. In fact `read_json` raises `ValueError` if any of them is set. The
docstring now says they aren't supported.
- **`Dataset.sort()`**: the summary line said the dataset can be sorted
by a "key function", but `key` is typed as `Union[str, List[str]]` and
callables aren't accepted. The summary now says "one or more key
columns".
- **Test**: adds `test_jsonl_rejects_unsupported_args`, a parametrized
test checking that each of the three arguments raises `ValueError` when
`lines=True`. Nothing covered this before.
- Removes a trailing space from that `ValueError` message.

This consolidates #66926 into this PR, following review feedback that
the two changes were too small to send separately.

## Related issues

Supersedes #66926.

## Additional information

I used AI assistance to prepare this change. I reviewed every changed
line and ran the tests above myself.

---------

Signed-off-by: viiccwen <[email protected]>
Co-authored-by: You-Cheng Lin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community data Ray Data-related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ray fails to serialize self-reference objects

1 participant