Skip to content

Make seekable True by default for arrow #1186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2023
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
10 changes: 9 additions & 1 deletion fsspec/implementations/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions fsspec/implementations/tests/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)