Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions python/ray/data/_internal/planner/plan_download_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ def get_file_size(uri_path, fs):
return file_sizes

def __call__(self, block: pa.Table) -> Iterator[pa.Table]:
if self._uri_column_name not in block.column_names:
raise ValueError(
"Ray Data tried to download URIs from a column named "
f"{self._uri_column_name!r}, but a column with that name doesn't "
"exist. Is the specified download column correct?"
)
Copy link

Choose a reason for hiding this comment

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

Bug: Column Check Fails on Non-PyArrow Tables

The column existence check accesses block.column_names before the block is guaranteed to be a PyArrow table. If the input isn't a PyArrow table (e.g., a pandas DataFrame), this can raise an AttributeError or lead to incorrect results.

Fix in Cursor Fix in Web


if not isinstance(block, pa.Table):
block = BlockAccessor.for_block(block).to_arrow()

Expand Down
2 changes: 1 addition & 1 deletion python/ray/data/tests/test_download_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_download_expression_invalid_uri_column(self):
ds_with_downloads = ds.with_column("bytes", download("non_existent_column"))

# Should raise error when trying to execute
with pytest.raises(Exception): # Could be KeyError or similar
with pytest.raises(ValueError):
ds_with_downloads.take_all()

def test_download_expression_with_null_uris(self):
Expand Down