Skip to content

Commit

Permalink
fix: ibis.connect always returns a backend
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Previously `ibis.connect` would return a `Table` object
when calling `connect` on a parquet/csv file. This now returns a backend
containing a single table created from that file. When possible users
may use `ibis.read` instead to read files into ibis tables.
  • Loading branch information
jcrist authored and gforsyth committed Dec 13, 2022
1 parent 954315c commit 2d5b155
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
7 changes: 2 additions & 5 deletions ibis/backends/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,6 @@ def connect(resource: Path | str, **kwargs: Any) -> BaseBackend:
Examples
--------
Connect to an on-disk parquet or csv file (uses duckdb by default):
>>> con = ibis.connect("/path/to/data.parquet")
>>> con = ibis.connect("/path/to/data.csv")
Connect to an in-memory duckdb database:
>>> con = ibis.connect("duckdb://")
Expand Down Expand Up @@ -799,7 +795,8 @@ def connect(resource: Path | str, **kwargs: Any) -> BaseBackend:
elif path.endswith((".parquet", ".csv", ".csv.gz")):
# Load parquet/csv/csv.gz files with duckdb by default
con = ibis.duckdb.connect(**kwargs)
return con.register(path)
con.register(path)
return con
else:
raise ValueError(f"Don't know how to connect to {resource!r}")

Expand Down
5 changes: 2 additions & 3 deletions ibis/backends/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import ibis.common.exceptions as com
import ibis.expr.datatypes as dt
import ibis.expr.operations as ops
import ibis.expr.types as ir
from ibis.util import guid


Expand Down Expand Up @@ -586,8 +585,8 @@ def test_connect_sqlite(url, ext, tmp_path):
)
def test_connect_local_file(out_method, extension, test_employee_data_1, tmp_path):
getattr(test_employee_data_1, out_method)(tmp_path / f"out.{extension}")
t = ibis.connect(tmp_path / f"out.{extension}")
assert isinstance(t, ir.Table)
con = ibis.connect(tmp_path / f"out.{extension}")
t = list(con.tables.values())[0]
assert not t.head().execute().empty


Expand Down

0 comments on commit 2d5b155

Please sign in to comment.