Skip to content

Commit 35da646

Browse files
authored
Make seekable True by default for arrow (#1186)
1 parent 6b2039c commit 35da646

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

fsspec/implementations/arrow.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def rm(self, path, recursive=False, maxdepth=None):
157157
self.fs.delete_file(path)
158158

159159
@wrap_exceptions
160-
def _open(self, path, mode="rb", block_size=None, seekable=False, **kwargs):
160+
def _open(self, path, mode="rb", block_size=None, seekable=True, **kwargs):
161161
if mode == "rb":
162162
if seekable:
163163
method = self.fs.open_input_file
@@ -202,6 +202,14 @@ def modified(self, path):
202202
path = self._strip_protocol(path)
203203
return self.fs.get_file_info(path).mtime
204204

205+
def cat_file(self, path, start=None, end=None, **kwargs):
206+
kwargs["seekable"] = start not in [None, 0]
207+
return super().cat_file(path, start=None, end=None, **kwargs)
208+
209+
def get_file(self, rpath, lpath, **kwargs):
210+
kwargs["seekable"] = False
211+
super().get_file(rpath, lpath, **kwargs)
212+
205213

206214
@mirror_from(
207215
"stream",

fsspec/implementations/tests/test_arrow.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,8 @@ def test_seekable(fs, remote_dir):
236236
for seekable in [True, False]:
237237
with fs.open(remote_dir + "/a.txt", "rb", seekable=seekable) as file:
238238
assert file.seekable() == seekable
239+
assert file.read() == data
240+
241+
with fs.open(remote_dir + "/a.txt", "rb", seekable=False) as file:
242+
with pytest.raises(IOError):
243+
file.seek(5)

0 commit comments

Comments
 (0)