Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
15 changes: 14 additions & 1 deletion python/pyarrow/parquet/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1887,10 +1887,23 @@ def read_table(source, *, columns=None, use_threads=True,
"the 'schema' argument is not supported when the "
"pyarrow.dataset module is not available"
)
if isinstance(source, list):
raise ValueError(
"the 'source' argument cannot be a list of files "
"when the pyarrow.dataset module is not available"
)

filesystem, path = _resolve_filesystem_and_path(source, filesystem)
if filesystem is not None:
if not filesystem.get_file_info(path).is_file:
raise ValueError(
"the 'source' argument should be "
"an existing .parquet file and not a directory, "
"when the pyarrow.dataset module is not available"
)

source = filesystem.open_input_file(path)
# TODO test that source is not a directory or a list

dataset = ParquetFile(
source, read_dictionary=read_dictionary,
binary_type=binary_type,
Expand Down
12 changes: 12 additions & 0 deletions python/pyarrow/tests/parquet/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

import os
import sys
from collections import OrderedDict
import io
import warnings
Expand Down Expand Up @@ -993,3 +994,14 @@ def test_checksum_write_to_dataset(tempdir):
# checksum verification enabled raises an exception
with pytest.raises(OSError, match="CRC checksum verification"):
_ = pq.read_table(corrupted_file_path, page_checksum_verification=True)


@pytest.mark.parametrize(
"source", ["/tmp/", ["/tmp/file1.parquet", "/tmp/file2.parquet"]])
def test_read_table_raises_value_error_when_ds_is_unavailable(
monkeypatch, source):
# GH-47728
monkeypatch.setitem(sys.modules, "pyarrow.dataset", None)

with pytest.raises(ValueError, match="the 'source' argument"):
pq.read_table(source=source)
Loading