From b3bbde12ed67fcbbfd809b043b5bc819f13bfa51 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Mon, 22 Apr 2024 07:28:51 -0400 Subject: [PATCH] fix(polars): ensure that reading from a compressed csv triggers in-memory read --- ibis/backends/polars/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ibis/backends/polars/__init__.py b/ibis/backends/polars/__init__.py index a09c8c0ff0fb..f2e4ffa24bed 100644 --- a/ibis/backends/polars/__init__.py +++ b/ibis/backends/polars/__init__.py @@ -183,10 +183,15 @@ def read_csv( path = normalize_filename(path) table_name = table_name or gen_name("read_csv") try: - self._add_table(table_name, pl.scan_csv(path, **kwargs)) + table = pl.scan_csv(path, **kwargs) + # triggers a schema computation to handle compressed csv inference + # and raise a compute error + table.schema # noqa: B018 except pl.exceptions.ComputeError: # handles compressed csvs - self._add_table(table_name, pl.read_csv(path, **kwargs)) + table = pl.read_csv(path, **kwargs) + + self._add_table(table_name, table) return self.table(table_name) def read_json(