diff --git a/altair/datasets/_readers.py b/altair/datasets/_readers.py index 3b122df10..f58fcd56d 100644 --- a/altair/datasets/_readers.py +++ b/altair/datasets/_readers.py @@ -98,6 +98,10 @@ def scan_fn(self, source: StrPath, /) -> Callable[..., IntoFrameT]: suffix = validate_suffix(source, is_ext_scan) return self._scan_fn[suffix] + def _response_hook(self, f): + # HACK: pyarrow wants the file obj + return f.read() + def dataset( self, name: DatasetName | LiteralString, @@ -133,7 +137,7 @@ def dataset( return fn(fp, **kwds) else: with self._opener.open(url) as f: - return fn(f.read(), **kwds) + return fn(self._response_hook(f), **kwds) def url( self, @@ -329,6 +333,9 @@ def __init__(self, name: _PyArrow, /) -> None: } self._scan_fn = {".parquet": pa_read_parquet} + def _response_hook(self, f): + return f + def _filter_reduce(predicates: tuple[Any, ...], constraints: Metadata, /) -> nw.Expr: """