-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(duckdb): expose loading extensions
- Loading branch information
Showing
2 changed files
with
76 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from __future__ import annotations | ||
|
||
import duckdb | ||
import pytest | ||
import sqlalchemy as sa | ||
|
||
import ibis | ||
from ibis.conftest import LINUX, SANDBOXED | ||
|
||
|
||
@pytest.mark.xfail( | ||
LINUX and SANDBOXED, | ||
reason="nix on linux cannot download duckdb extensions or data due to sandboxing", | ||
raises=sa.exc.OperationalError, | ||
) | ||
def test_connect_extensions(): | ||
con = ibis.duckdb.connect(extensions=["s3", "sqlite"]) | ||
results = con.raw_sql( | ||
""" | ||
SELECT loaded FROM duckdb_extensions() | ||
WHERE extension_name = 'httpfs' OR extension_name = 'sqlite' | ||
""" | ||
).fetchall() | ||
assert all(loaded for (loaded,) in results) | ||
|
||
|
||
@pytest.mark.xfail( | ||
LINUX and SANDBOXED, | ||
reason="nix on linux cannot download duckdb extensions or data due to sandboxing", | ||
raises=duckdb.IOException, | ||
) | ||
def test_load_extension(): | ||
con = ibis.duckdb.connect() | ||
con.load_extension("s3") | ||
con.load_extension("sqlite") | ||
results = con.raw_sql( | ||
""" | ||
SELECT loaded FROM duckdb_extensions() | ||
WHERE extension_name = 'httpfs' OR extension_name = 'sqlite' | ||
""" | ||
).fetchall() | ||
assert all(loaded for (loaded,) in results) |