Skip to content

[Data] Added a SQL API - #55038

Open
soffer-anyscale wants to merge 85 commits into
masterfrom
data_sql
Open

soffer-anyscale wants to merge 85 commits into
masterfrom
data_sql

Conversation

@soffer-anyscale

@soffer-anyscale soffer-anyscale commented Jul 30, 2025 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

This PR introduces a comprehensive SQL API for Ray Datasets, enabling users to execute standard SQL queries on distributed data using Ray's parallel processing capabilities. This addresses a significant user need for familiar SQL syntax when working with large-scale distributed datasets.

Key benefits:

  • Familiar Interface: Allows data analysts and engineers to use standard SQL syntax with Ray Datasets
  • Distributed Execution: Leverages Ray's distributed computing for scalable SQL query processing
  • Seamless Integration: SQL results return as Ray Datasets, maintaining full compatibility with existing Ray Data workflows
  • Production Ready: Includes comprehensive error handling, configuration options, and optimization features

Core Features:

  • Standard SQL operations: SELECT, WHERE, JOIN, GROUP BY, ORDER BY, LIMIT
  • Aggregate functions: COUNT, SUM, AVG, MIN, MAX, STD
  • String functions: UPPER, LOWER
  • All join types: INNER, LEFT, RIGHT, FULL OUTER
  • Automatic table registration and schema inference
  • Query optimization using SQLGlot
  • Integration with Ray's DataContext for configuration

Checks


Note

Introduce an experimental Ray Data SQL API with execution engine, SQLGlot/DataFusion optimization, configuration, comprehensive docs, tests, and dependency updates.

  • Data/SQL (experimental):
    • Add new SQL engine under python/ray/data/experimental/sql/* (parser/compiler via SQLGlot, execution for SELECT/WHERE/JOIN/GROUP BY/ORDER BY/LIMIT, aggregates, validators, registry/schema, exceptions).
    • Integrate optional DataFusion optimizer (engines/datafusion/*) with hint-driven execution.
    • Provide user-facing API in experimental/sql_api.py (sql, register, list_tables, clear_tables) and config via DataContext (sql_* and sql_use_datafusion).
  • Docs:
    • Add SQL docs: doc/source/data/sql*.rst, API reference doc/source/data/api/sql.rst; update navigation and landing pages.
  • Tests/Build:
    • Add SQL tests (test_sql_api.py, test_sql_datafusion.py, test_sql_optimizers.py) and BUILD targets.
  • Deps:
    • Add sqlglot to requirements.

Written by Cursor Bugbot for commit 7b68d1f. This will update automatically on new commits. Configure here.

Signed-off-by: soffer-anyscale <[email protected]>
@soffer-anyscale
soffer-anyscale requested a review from a team as a code owner July 30, 2025 02:29
@soffer-anyscale soffer-anyscale changed the title Data sql [Data] Added a SQL API Jul 30, 2025

@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.

Summary of Changes

Hello @soffer-anyscale, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request delivers a significant new feature to Ray Data: a native SQL interface. It enables users to interact with distributed Ray Datasets using familiar SQL syntax, translating SQL queries into efficient Ray Data operations. The implementation follows Ray Data's lazy evaluation patterns and integrates deeply with the existing API, providing a powerful and scalable tool for data manipulation.

Highlights

  • New SQL API for Ray Datasets: This PR introduces a comprehensive SQL API, ray.data.sql, allowing users to execute standard SQL queries directly on Ray Datasets. This includes support for SELECT, WHERE, JOIN, GROUP BY, ORDER BY, LIMIT, and various aggregate and string functions.
  • Distributed Execution & Integration: The SQL API leverages Ray's distributed computing capabilities for scalable query processing. Results are returned as Ray Datasets, ensuring seamless integration with existing Ray Data workflows and allowing for method chaining with other Ray Data operations.
  • Architecture & Components: A new ray.data.sql package is added, comprising several key components: a SQLParser (using SQLGlot), ASTOptimizer and LogicalPlanner for query optimization and planning, a QueryExecutor that applies Ray Data operations, and a DatasetRegistry for managing registered tables and their schemas. An ExpressionCompiler converts SQL expressions into Python callables.
  • Automatic Table Registration & Schema Inference: The API supports automatic table registration, where Ray Datasets in the caller's scope can be recognized by their variable names. It also includes automatic schema inference from registered datasets.
  • Testing and Examples: Comprehensive unit tests (test_sql_api.py) and a dedicated testing.py module with TestRunner and ExampleRunner are included to validate the engine's functionality and demonstrate its usage with various SQL scenarios.
  • Dependency Update: The sqlglot library (version 27.4.1) is added as a new dependency to python/requirements/ml/data-test-requirements.txt to power the SQL parsing and optimization.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@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 is an excellent and comprehensive pull request that introduces a powerful SQL API for Ray Datasets. The architecture is well-thought-out, with a clear separation of concerns for parsing, optimization, and execution. The integration with sqlglot is a solid choice.

I've found a few issues that should be addressed before merging. Most notably, there is a critical bug in the LIMIT clause implementation that needs to be fixed. I've also identified a high-severity issue in the validation logic for aggregate functions and several medium-severity issues related to API design, maintainability, and robustness. My detailed comments and suggestions should help in polishing this feature for its release.

Comment thread python/ray/data/sql/abstractions.py Resolved
Comment thread python/ray/data/sql/README.md Resolved
Comment thread python/ray/data/sql/__init__.py Resolved
Comment thread python/ray/data/sql/config.py Resolved
Comment thread python/ray/data/sql/core.py Resolved
Comment thread python/ray/data/sql/testing.py Resolved
Comment thread python/ray/data/sql/utils.py Resolved
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation data Ray Data-related issues labels Aug 15, 2025
Signed-off-by: soffer-anyscale <[email protected]>
Signed-off-by: soffer-anyscale <[email protected]>
Signed-off-by: soffer-anyscale <[email protected]>
- Fix _check_unsupported_features method to avoid TypeError with ast.find_all()
- Change from passing tuple of dict_keys to iterating over feature types individually
- Fix SUPPORTED_STATEMENTS isinstance check to avoid unnecessary tuple conversion
- Resolves 'isinstance() arg 2 must be a type, a tuple of types, or a union' error

Signed-off-by: soffer-anyscale <[email protected]>
- Add missing arguments to __init__ method docstrings for all exception classes
- Add missing arguments to __init__ method docstrings for all handler classes
- Add missing arguments to __init__ method docstrings for parser classes
- Add missing type hints to utility functions
- Remove Args sections from class docstrings (moved to __init__ methods)
- All changes follow pydoclint requirements and Ray coding standards

Signed-off-by: soffer-anyscale <[email protected]>
- Update SQL ARCHITECTURE.md and README.md with latest implementation details
- Improve SQL execution engine and validation logic
- Update Ray Data __init__.py to include SQL functionality

Signed-off-by: soffer-anyscale <[email protected]>
Signed-off-by: soffer-anyscale <[email protected]>
Signed-off-by: soffer-anyscale <[email protected]>
Signed-off-by: soffer-anyscale <[email protected]>
Signed-off-by: soffer-anyscale <[email protected]>
Signed-off-by: soffer-anyscale <[email protected]>
- Comprehensive SQL support: SELECT, JOIN, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, OFFSET, UNION, CTEs
- Ray Dataset integration: All operations use Ray's native Dataset API for optimal performance
- Advanced expressions: Support for CASE statements, arithmetic, string functions in all contexts
- Performance optimized: Multi-level caching, lazy evaluation, efficient memory usage
- Production ready: Proper error handling, validation, and monitoring
- Experimental API: Marked with @publicapi(stability='alpha') for gradual rollout
- Comprehensive tests: 91 test functions covering all SQL functionality
- Complete documentation: User guides, API reference, and examples

Signed-off-by: soffer-anyscale <[email protected]>
- Remove over-engineered caching and complex optimizations
- Simplify docstrings to match Ray's clean, concise style
- Align with Ray Data's straightforward, elegant patterns
- Keep essential functionality while removing complexity
- Maintain performance while improving maintainability

Signed-off-by: soffer-anyscale <[email protected]>
- Mark all public functions with @publicapi(stability='alpha')
- Ensure consistent experimental API marking throughout
- Meet Ray's requirements for new API stability levels

Signed-off-by: soffer-anyscale <[email protected]>
cursor[bot]

This comment was marked as outdated.

- Fix RTD build by updating sql.rst to reference only existing functions
  - Removed references to non-existent classes (RaySQL, SQLConfig, LogLevel)
  - Removed references to non-existent functions (get_engine, get_registry, get_schema)
  - Updated register_table to register (actual function name)
  - Now only documents: sql, register, list_tables, clear_tables

- Fix distributed OFFSET bug in LimitHandler
  - Previous itertools.count() approach failed in distributed execution
  - Each partition had its own counter, causing incorrect row skipping
  - Now uses take_all() + Python slicing for correctness
  - Added warning about OFFSET performance implications

- Fix LIMIT 0 bug to return empty dataset correctly
  - Previously returned full dataset instead of empty one
  - Added explicit check for limit_value == 0

- Remove unused offset_limit_map function

Signed-off-by: soffer-anyscale <[email protected]>
Apply Douglas's documentation style patterns:
- Add overview section explaining what the SQL API is
- Include common use cases section explaining why to use it
- Better organize API reference with logical groupings
- Add context and explanatory text before API details
- Use sentence case in section descriptions
- Remove 'currently' for timeless documentation
- Structure follows: What is it -> Why use it -> How to use it

Signed-off-by: soffer-anyscale <[email protected]>
Fix ModuleNotFoundError: No module named 'ray.data.experimental.sql.execution.engine'

The execution/__init__.py was trying to import SQLExecutionEngine from
a non-existent engine.py module. The actual class is QueryExecutor in
executor.py.

Changes:
- Update import from 'execution.engine' to 'execution.executor'
- Update class name from SQLExecutionEngine to QueryExecutor
- Update module docstring to reference correct class name
- Update __all__ export list

This fixes the test failures in test_sql_api and test_sql_datafusion.

Signed-off-by: soffer-anyscale <[email protected]>
…ation

- Merge test_sql_datafusion.py and test_sql_optimizers.py into test_sql_api.py
- Remove internal implementation tests (DataFusionOptimizer, etc.)
- Focus on public APIs: sql(), register(), list_tables(), clear_tables(), config
- Use sql_engine fixture to parametrize tests for both SQLGlot and DataFusion
- Update BUILD.bazel to remove deleted test targets
- All tests now run with both engines to ensure consistent behavior

Signed-off-by: soffer-anyscale <[email protected]>
- Add all sql_* DataContext fields to config proxy
- Properties: dialect, log_level, case_sensitive, strict_mode,
  enable_optimization, max_join_partitions, enable_predicate_pushdown,
  enable_projection_pushdown, query_timeout_seconds,
  enable_sqlglot_optimizer, use_datafusion
- All properties delegate to DataContext for consistency
- Property names follow convention: remove sql_ prefix (since already in SQL namespace)
- Add comprehensive test coverage for all config properties
- Ensures all SQL settings accessible via both config proxy and DataContext

Signed-off-by: soffer-anyscale <[email protected]>
- Mark sql/__init__.py as internal implementation
- Direct users to sql_api.py for public API
- Remove module-level callable pattern (overly complex)
- Simplify __all__ exports to only internal components
- Add clear documentation about proper API usage
- Follows Ray Data pattern of clear public API boundaries

Signed-off-by: soffer-anyscale <[email protected]>
cursor[bot]

This comment was marked as outdated.

- Created ray/python/ray/data/sql.py as the public API module
  - Exports all SQL functions: sql(), register(), list_tables(), clear_tables(), get_schema()
  - Exports configuration: SQLConfig, SQLDialect, LogLevel
  - Exports all exception classes
  - Provides register_table alias for register()

- Updated ray/python/ray/data/__init__.py to import from public API
  - Makes functions available at ray.data.sql() level
  - Hides experimental paths from users

- Fixed race condition in ExpressionCompiler._compilation_cache
  - Added threading.Lock for thread-safe cache access
  - Implemented double-checked locking pattern
  - Protected cache operations in compile(), clear_compilation_cache(), get_cache_stats()

- Fixed missing class definitions
  - Added TableSchema dataclass in schema/manager.py
  - Removed incorrect TableManager import in registry/__init__.py

- Added comprehensive auto-discovery test coverage (29 tests total)
  - test_sql_explicit_registration_precedence
  - test_sql_auto_discovery_with_cte
  - test_sql_auto_discovery_table_not_found
  - test_sql_auto_discovery_with_aliases_and_joins
  - test_sql_auto_discovery_with_range
  - test_sql_auto_discovery_cleanup_with_error
  - test_sql_auto_discovery_with_explicit_kwargs
  - test_sql_auto_discovery_mixed_local_and_global
  - test_sql_auto_discovery_repeated_queries

- Updated documentation to use public API paths
  - Fixed import statements in sql-examples.rst
  - Updated api/sql.rst to reference ray.data.sql module
  - Fixed Vale linting issues by wrapping SQL keywords in backticks

- Added third-party library URLs to code comments
  - SQLGlot: https://github.com/tobymao/sqlglot
  - Apache DataFusion: https://datafusion.apache.org/

- Code quality improvements
  - Added type hints to ExpressionCompiler.__init__()
  - Added comprehensive docstrings and comments
  - Fixed linting issues (trailing whitespace, unused variables)
  - Improved code organization and modularity

Signed-off-by: soffer-anyscale <[email protected]>
- Fixed doctest failures in sql.rst, sql-contributing.rst, sql-examples.rst,
  sql-quickstart.rst, sql-user-guide.rst, and sql-validation.rst
- Refactored large functions in datafusion_optimizer.py:
  * Split _calculate_smart_sample_size() (144 lines) into 8 focused functions
  * Split _extract_optimizations() (117 lines) into 5 focused functions
- Consolidated DataFusion configuration constants into new config.py module
- Enhanced inline comments in complex sections of expressions.py
- Added missing type hints in utils.py and datafusion_optimizer.py
- Improved error messages with better context and examples
- Added comprehensive test coverage with test_sql_api_extended.py (29 new tests)
- Fixed pydoclint issues in core.py and datafusion_optimizer.py
- Applied black formatting fixes

All pre-commit hooks passing (ruff, black, pydoclint).

Signed-off-by: soffer-anyscale <[email protected]>
The documentation was using 'currentmodule:: ray.data.sql' which caused
Sphinx to try importing functions as submodules (e.g., ray.data.sql.clear_tables)
instead of as functions from the module.

Since ray.data.sql is a module file (.py), not a package, we need to use
fully qualified paths in the autodoc directives.

Fixed by:
- Removing the 'currentmodule' directive
- Using full paths (ray.data.sql.function_name) in autosummary and autofunction directives

This resolves the 'no module named ray.data.sql' error in Read the Docs build.

Signed-off-by: soffer-anyscale <[email protected]>
- Merge all tests from test_sql_api_extended.py into test_sql_api.py
- Remove duplicate test_sql_api_extended.py file
- Remove trailing newline from datafusion/config.py
- All tests now organized with clear section headers

Signed-off-by: soffer-anyscale <[email protected]>
- Add sqlglot to autodoc_mock_imports list in doc/source/conf.py
- Update sql.rst to use currentmodule directive consistently with other Ray docs
- Simplify autosummary and autofunction references to use short names

Signed-off-by: soffer-anyscale <[email protected]>
@soffer-anyscale
soffer-anyscale requested a review from a team as a code owner October 13, 2025 23:09
- Fix title underlines in sql-user-guide.rst and sql-validation.rst
- Fix toctree indentation in data.rst and user-guide.rst
- Update broken cross-references to use correct labels
- Remove references to non-existent pages

Signed-off-by: soffer-anyscale <[email protected]>
…les, remove emojis

- Fixed invalid SQLConfig parameters in code examples (removed non-existent parameters like enable_auto_registration, enable_query_timing, enable_streaming_execution, max_memory_usage_gb, etc.)
- Added minimal migration examples for PostgreSQL, MySQL, and Snowflake with dialect support
- Removed all emojis from SQL documentation (44 instances replaced with plain text)
- Fixed missing label reference for data_sql_examples
- Added sql-validation.rst and sql-contributing.rst to toctree
- Updated SQL docs to follow Google style guide (removed 'currently', 'etc.')
- Fixed import statements to use correct 'from' syntax
- All code examples now use only valid SQLConfig parameters verified in codebase

Signed-off-by: soffer-anyscale <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Oct 29, 2025
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no more activity in the 14 days
since being marked stale.

Please feel free to reopen or open a new pull request if you'd still like this to be addressed.

Again, you can always ask for help on our discussion forum or Ray's public slack channel.

Thanks again for your contribution!

@github-actions github-actions Bot closed this Nov 12, 2025
- Add URLs to 3rd party libraries (SQLGlot, DataFusion) in module docstrings
- Split large functions in core.py and executor.py for better readability
- Improve docstrings following Ray Data standards with Args/Returns/Raises
- Remove unused imports and variables
- Fix f-string syntax for Python 3.9 compatibility
- Improve error handling and function organization
- Enhance code modularity and naming conventions

Signed-off-by: soffer-anyscale <[email protected]>
sql as _sql_func,
)

# Make sql() callable as both ray.data.sql() and ray.data.sql.sql()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Module Shadowing Breaks SQL Imports

The line sql = _sql_func overwrites the sql module with the sql function, breaking module imports. After this assignment, users cannot access ray.data.sql.SQLConfig or use from ray.data.sql import ... because ray.data.sql is no longer a module but a function. This conflicts with the comment on line 80 stating "users can do: from ray.data.sql import ...". Either remove this reassignment or use a different name like sql_query for the function to avoid shadowing the module.

Fix in Cursor Fix in Web

@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Nov 15, 2025
@daiping8

Copy link
Copy Markdown
Contributor

This is a great job, which has greatly helped us use ray data. However, I noticed that this seems to be an incomplete PR, with some features still needing implementation, such as set operations and deduplication, window functions, and DataFusion optimization.

I would like to know:

  1. Will this PR continue to be advanced until it gets merged?
  2. Can I easily participate in the development of the features that need improvement?

Thank you again.

@dstrodtman

Copy link
Copy Markdown
Contributor

Hi @soffer-anyscale, heads-up: master converted doc pages this PR edits from reStructuredText to MyST Markdown, so those edits need to move to the .md files when you rebase:

If you'd like help translating your edits to Markdown, DM me (Douglas Strodtman) on the Ray Slack and I'll help. If you'd rather handle it yourself, the repo has a Claude Code skill for this conversion at doc/.claude/skills/rst-to-myst/. Most small edits don't need it, though: any coding agent can translate them without the skill loaded.

richardliaw pushed a commit that referenced this pull request Sep 24, 2026
## Description

Style and grammar pass on Ray Data docs against Ray's [writing-style
guide](https://docs.ray.io/en/master/ray-contribute/writing-style.html).
Prose only: no code, `literalinclude` blocks, URLs, anchors, or role
targets changed.

Stacked on #66412, which is stacked on #66381, #66375, and #66352.
Review and merge those first. This branch targets
`doc-1524-data-vale-cleanup`. It combines this PR's original
comparisons-page pass with the custom datasource pass first opened as
#66416.

### `comparisons.md`

- Renames the legacy "Datasets" product name to "Ray Data". The page
already used "Ray Data" for the same subject in the same lists.
Third-party "Torch datasets" and "TensorFlow datasets" are unchanged.
- Fixes `SageMaker` and `BentoML` casing, which #66412 left as
intentional alerts for this pass.
- Uses contractions, active voice, second person, and "such as" for
examples.
- Removes "our blog post", "3rd", "e.g.", mid-sentence colons, and
semicolons.
- Fixes the grammar of the BentoML-and-Spark sentence and subject-verb
agreement for "TensorFlow datasets".
- Sentence-cases the dropdown titles and makes them parallel.
- Adds a lead-in sentence to each comparison list and uses the
`**Term**: explanation` definition-list form from the style guide.
- Collapses runs of blank lines between dropdowns to one.

### `custom-datasource-example.md`

This is the page whose `<!-- vale off -->` blocks #66412 removed so the
future-tense prose they hid could be fixed.

- Replaces the three "you'll" future-tense sentences with present tense.
- Names Ray Data as the actor in "file types that aren't natively
supported" and "Images are already supported".
- Replaces "functionality" with "behavior", "Once you've implemented"
with "After you implement", and the "(for example, `"png"`)"
parenthetical with "such as".
- Cuts the time-relative "in the future" from the write-interface note
but keeps "is under active development and might change", which is the
stability warning.
- Corrects the block types. The page said blocks can be dictionaries of
NumPy arrays, but `Block` in `block.py` is only a PyArrow table or a
pandas DataFrame, including at the commit the page links to. NumPy
dictionaries are a batch format. This is a factual correction.
- Sentence-cases the title: "Advanced: Read and write custom file
types".
- Updates the one link in `loading-data.md` whose text quotes the old
title.

## Why this isn't a duplicate

No other open PR edits `comparisons.md`, `custom-datasource-example.md`,
or `doc_code/custom_datasource_example.py`. #55038 adds an experimental
SQL API and SQL docs but doesn't edit these pages. See the related
question below. I also checked the open Data PRs that mention
datasources, including #65760, #57239, and #55467.

## Questions for reviewers

Apart from the block-types correction, this pass kept the scope of every
claim. These existing claims might be stale, and a Ray Data maintainer
is better placed to judge them:

- **Third-party feature claims on `comparisons.md`:** Petastorm supports
only Parquet, NVTabular supports only Parquet, CSV, and Avro, TensorFlow
datasets support only file interleaving across worker shards, and Torch
datasets have no I/O layer.
- **SQL interface:** "Ray Data doesn't have a SQL interface" would go
stale if #55038 lands.
- **Comparisons with no measure:** "a streaming paradigm that's better
suited to GPU workloads" and "can't effectively handle large datasets".
The style guide's "Keep comparisons precise" section applies, but no
source for a measure is on the page.
- **Repeated comparison points:** the training-ingest dropdowns repeat
three points almost word for word. A single comparison table might read
better. That moves content, so it isn't in this PR.
- **Duplicate headings:** `custom-datasource-example.md` has two H3s
named "Implement the constructor", one under reading and one under
writing. "Implement the datasource constructor" and "Implement the
datasink constructor" would make the right-side TOC clearer. I left them
as they are.

## Verification

- `vale` with Vale 3.12, run from the repo root: 0 alerts on
`comparisons.md`, down from 24, and 0 on `custom-datasource-example.md`,
down from 6. `loading-data.md` has no alerts on the edited line.
- `codespell`: no hits.
- The pre-commit hooks passed on each commit.
- A structural check against each pre-edit file confirmed the code-fence
count, role targets, anchors, and URLs are unchanged.
- For the reworded title, a grep for inbound links found the `{ref}` in
`loading-data.md`, updated here, and a toctree entry in `user-guide.md`,
which doesn't depend on the title. No links use the heading's implicit
slug.
- I didn't run a local Sphinx build. The Read the Docs preview covers
rendering.

## AI assistance

I made these edits with AI assistance (Claude Code) and reviewed the
full diff by hand.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
## Description

Style and grammar pass on Ray Data docs against Ray's [writing-style
guide](https://docs.ray.io/en/master/ray-contribute/writing-style.html).
Prose only: no code, `literalinclude` blocks, URLs, anchors, or role
targets changed.

Stacked on ray-project#66412, which is stacked on ray-project#66381, ray-project#66375, and ray-project#66352.
Review and merge those first. This branch targets
`doc-1524-data-vale-cleanup`. It combines this PR's original
comparisons-page pass with the custom datasource pass first opened as
ray-project#66416.

### `comparisons.md`

- Renames the legacy "Datasets" product name to "Ray Data". The page
already used "Ray Data" for the same subject in the same lists.
Third-party "Torch datasets" and "TensorFlow datasets" are unchanged.
- Fixes `SageMaker` and `BentoML` casing, which ray-project#66412 left as
intentional alerts for this pass.
- Uses contractions, active voice, second person, and "such as" for
examples.
- Removes "our blog post", "3rd", "e.g.", mid-sentence colons, and
semicolons.
- Fixes the grammar of the BentoML-and-Spark sentence and subject-verb
agreement for "TensorFlow datasets".
- Sentence-cases the dropdown titles and makes them parallel.
- Adds a lead-in sentence to each comparison list and uses the
`**Term**: explanation` definition-list form from the style guide.
- Collapses runs of blank lines between dropdowns to one.

### `custom-datasource-example.md`

This is the page whose `<!-- vale off -->` blocks ray-project#66412 removed so the
future-tense prose they hid could be fixed.

- Replaces the three "you'll" future-tense sentences with present tense.
- Names Ray Data as the actor in "file types that aren't natively
supported" and "Images are already supported".
- Replaces "functionality" with "behavior", "Once you've implemented"
with "After you implement", and the "(for example, `"png"`)"
parenthetical with "such as".
- Cuts the time-relative "in the future" from the write-interface note
but keeps "is under active development and might change", which is the
stability warning.
- Corrects the block types. The page said blocks can be dictionaries of
NumPy arrays, but `Block` in `block.py` is only a PyArrow table or a
pandas DataFrame, including at the commit the page links to. NumPy
dictionaries are a batch format. This is a factual correction.
- Sentence-cases the title: "Advanced: Read and write custom file
types".
- Updates the one link in `loading-data.md` whose text quotes the old
title.

## Why this isn't a duplicate

No other open PR edits `comparisons.md`, `custom-datasource-example.md`,
or `doc_code/custom_datasource_example.py`. ray-project#55038 adds an experimental
SQL API and SQL docs but doesn't edit these pages. See the related
question below. I also checked the open Data PRs that mention
datasources, including ray-project#65760, ray-project#57239, and ray-project#55467.

## Questions for reviewers

Apart from the block-types correction, this pass kept the scope of every
claim. These existing claims might be stale, and a Ray Data maintainer
is better placed to judge them:

- **Third-party feature claims on `comparisons.md`:** Petastorm supports
only Parquet, NVTabular supports only Parquet, CSV, and Avro, TensorFlow
datasets support only file interleaving across worker shards, and Torch
datasets have no I/O layer.
- **SQL interface:** "Ray Data doesn't have a SQL interface" would go
stale if ray-project#55038 lands.
- **Comparisons with no measure:** "a streaming paradigm that's better
suited to GPU workloads" and "can't effectively handle large datasets".
The style guide's "Keep comparisons precise" section applies, but no
source for a measure is on the page.
- **Repeated comparison points:** the training-ingest dropdowns repeat
three points almost word for word. A single comparison table might read
better. That moves content, so it isn't in this PR.
- **Duplicate headings:** `custom-datasource-example.md` has two H3s
named "Implement the constructor", one under reading and one under
writing. "Implement the datasource constructor" and "Implement the
datasink constructor" would make the right-side TOC clearer. I left them
as they are.

## Verification

- `vale` with Vale 3.12, run from the repo root: 0 alerts on
`comparisons.md`, down from 24, and 0 on `custom-datasource-example.md`,
down from 6. `loading-data.md` has no alerts on the edited line.
- `codespell`: no hits.
- The pre-commit hooks passed on each commit.
- A structural check against each pre-edit file confirmed the code-fence
count, role targets, anchors, and URLs are unchanged.
- For the reworded title, a grep for inbound links found the `{ref}` in
`loading-data.md`, updated here, and a toctree entry in `user-guide.md`,
which doesn't depend on the title. No links use the heading's implicit
slug.
- I didn't run a local Sphinx build. The Read the Docs preview covers
rendering.

## AI assistance

I made these edits with AI assistance (Claude Code) and reviewed the
full diff by hand.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues docs An issue or change related to documentation unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants