Skip to content

Commit

Permalink
fix(polars): ensure that reading from a compressed csv triggers in-me…
Browse files Browse the repository at this point in the history
…mory read
  • Loading branch information
cpcloud committed Apr 22, 2024
1 parent caa113b commit b3bbde1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ibis/backends/polars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b3bbde1

Please sign in to comment.