diff --git a/fsspec/implementations/arrow.py b/fsspec/implementations/arrow.py index c89475d7a..3b1048acd 100644 --- a/fsspec/implementations/arrow.py +++ b/fsspec/implementations/arrow.py @@ -157,7 +157,7 @@ def rm(self, path, recursive=False, maxdepth=None): self.fs.delete_file(path) @wrap_exceptions - def _open(self, path, mode="rb", block_size=None, seekable=False, **kwargs): + def _open(self, path, mode="rb", block_size=None, seekable=True, **kwargs): if mode == "rb": if seekable: method = self.fs.open_input_file @@ -202,6 +202,14 @@ def modified(self, path): path = self._strip_protocol(path) return self.fs.get_file_info(path).mtime + def cat_file(self, path, start=None, end=None, **kwargs): + kwargs["seekable"] = start not in [None, 0] + return super().cat_file(path, start=None, end=None, **kwargs) + + def get_file(self, rpath, lpath, **kwargs): + kwargs["seekable"] = False + super().get_file(rpath, lpath, **kwargs) + @mirror_from( "stream", diff --git a/fsspec/implementations/tests/test_arrow.py b/fsspec/implementations/tests/test_arrow.py index a31966570..689ad24bf 100644 --- a/fsspec/implementations/tests/test_arrow.py +++ b/fsspec/implementations/tests/test_arrow.py @@ -236,3 +236,8 @@ def test_seekable(fs, remote_dir): for seekable in [True, False]: with fs.open(remote_dir + "/a.txt", "rb", seekable=seekable) as file: assert file.seekable() == seekable + assert file.read() == data + + with fs.open(remote_dir + "/a.txt", "rb", seekable=False) as file: + with pytest.raises(IOError): + file.seek(5)