Skip to content

Commit

Permalink
feat(snowflake): allow empty url when using ibis.connect (#8428)
Browse files Browse the repository at this point in the history
Follow-up to #8422 to support that behavior in `ibis.connect()`.
  • Loading branch information
cpcloud authored Feb 22, 2024
1 parent ad1f53a commit 0275c9b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
26 changes: 15 additions & 11 deletions ibis/backends/snowflake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,21 @@ def _from_url(self, url: str, **kwargs):
"""

url = urlparse(url)
database, schema = url.path[1:].split("/", 1)
query_params = parse_qs(url.query)
(warehouse,) = query_params.pop("warehouse", (None,))
connect_args = {
"user": url.username,
"password": url.password or "",
"account": url.hostname,
"warehouse": warehouse,
"database": database or "",
"schema": schema or "",
}
if url.path:
database, schema = url.path[1:].split("/", 1)
query_params = parse_qs(url.query)
(warehouse,) = query_params.pop("warehouse", (None,))
connect_args = {
"user": url.username,
"password": url.password or "",
"account": url.hostname,
"warehouse": warehouse,
"database": database or "",
"schema": schema or "",
}
else:
connect_args = {}
query_params = {}

for name, value in query_params.items():
if len(value) > 1:
Expand Down
3 changes: 3 additions & 0 deletions ibis/backends/snowflake/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,6 @@ def test_compile_does_not_make_requests(con, mocker):
def test_no_argument_connection():
con = ibis.snowflake.connect()
assert con.list_tables() is not None

con = ibis.connect("snowflake://")
assert con.list_tables() is not None

0 comments on commit 0275c9b

Please sign in to comment.