From 42f45fe59da492897f0449468a3036384be34214 Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Thu, 15 Feb 2024 14:36:12 -0500 Subject: [PATCH] fix(duckdb): allow connection to motherduck via ibis.connect (#8357) ## Description of changes Our `_from_url` was a little aggressive in calling `Path().absolute()` on targets. Since we already handle that in `duckdb.do_connect` we can use `urlparse` to rip out the appropriate bits and forward them. ## Issues closed Fixes #8355 --- ibis/backends/base/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ibis/backends/base/__init__.py b/ibis/backends/base/__init__.py index f5419eaea469..3235c2636547 100644 --- a/ibis/backends/base/__init__.py +++ b/ibis/backends/base/__init__.py @@ -1433,9 +1433,14 @@ def _from_url(self, url: str, **kwargs) -> BaseBackend: url = urlparse(url) netloc = url.netloc parts = list(filter(None, (netloc, url.path[bool(netloc) :]))) - database = ( - Path(*parts).absolute() if parts and parts != [":memory:"] else ":memory:" - ) + database = Path(*parts) if parts and parts != [":memory:"] else ":memory:" + if (strdatabase := str(database)).startswith("md:") or strdatabase.startswith( + "motherduck:" + ): + database = strdatabase + elif isinstance(database, Path): + database = database.absolute() + query_params = parse_qs(url.query) for name, value in query_params.items():