Skip to content

Commit

Permalink
refactor(duckdb): replace register usage with read
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek authored and jcrist committed Sep 13, 2024
1 parent 34c465c commit 56b8ce4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 8 additions & 3 deletions ibis/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1425,10 +1425,15 @@ def connect(resource: Path | str, **kwargs: Any) -> BaseBackend:
return ibis.duckdb.connect(path, **kwargs)
elif path.endswith((".sqlite", ".db")):
return ibis.sqlite.connect(path, **kwargs)
elif path.endswith((".parquet", ".csv", ".csv.gz")):
# Load parquet/csv/csv.gz files with duckdb by default
elif path.endswith((".csv", ".csv.gz")):
# Load csv/csv.gz files with duckdb by default
con = ibis.duckdb.connect(**kwargs)
con.register(path)
con.read_csv(path)
return con
elif path.endswith(".parquet"):
# Load parquet files with duckdb by default
con = ibis.duckdb.connect(**kwargs)
con.read_parquet(path)
return con
else:
raise ValueError(f"Don't know how to connect to {resource!r}")
Expand Down
4 changes: 1 addition & 3 deletions ibis/backends/duckdb/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ def test_connect_local_file(out_method, extension, tmp_path):
df = pd.DataFrame({"a": [1, 2, 3]})
path = tmp_path / f"out.{extension}"
getattr(df, out_method)(path)
with pytest.warns(FutureWarning, match="v9.1"):
# ibis.connect uses con.register
con = ibis.connect(path)
con = ibis.connect(path)
t = next(iter(con.tables.values()))
assert not t.head().execute().empty

Expand Down

0 comments on commit 56b8ce4

Please sign in to comment.