From b929beca63c550dca3eb763755b7ff8c2a6a211a Mon Sep 17 00:00:00 2001 From: Adrian Ehrsam Date: Tue, 25 Jun 2024 14:41:50 +0200 Subject: [PATCH] use correct base path --- deltalake2db/duckdb.py | 11 ++++++++--- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/deltalake2db/duckdb.py b/deltalake2db/duckdb.py index 216fd1e..45d5eae 100644 --- a/deltalake2db/duckdb.py +++ b/deltalake2db/duckdb.py @@ -273,12 +273,17 @@ def get_sql_for_delta_expr( *, get_credential: "Optional[Callable[[str], Optional[TokenCredential]]]" = None, ) -> ex.Select: + from deltalake import DeltaTable from .sql_utils import read_parquet, union, filter_via_dict account_name_path = None + base_path = ( + dt.table_uri + if isinstance(dt, DeltaTable) + else (dt if isinstance(dt, str) else str(dt.absolute())) + ) + base_path = base_path.removesuffix("/") if isinstance(dt, Path) or isinstance(dt, str): - from deltalake import DeltaTable - path_for_delta, storage_options_for_delta = get_storage_options_object_store( dt, storage_options, get_credential ) @@ -323,7 +328,7 @@ def get_sql_for_delta_expr( continue if action_filter and not action_filter(ac): continue - fullpath = dt.table_uri.removesuffix("/") + "/" + ac["path"] + fullpath = base_path + "/" + ac["path"] with duck_con.cursor() as cur: cur.execute(f"select name from parquet_schema('{fullpath}')") cols: list[str] = [c[0] for c in cur.fetchall()] diff --git a/pyproject.toml b/pyproject.toml index 61d5518..e3c17c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "deltalake2db" -version = "0.3.9" +version = "0.4.0" description = "" authors = ["Adrian Ehrsam "] license = "MIT"