Skip to content

Commit

Permalink
Merge pull request #152 from jwills/jwills_urlparse_path
Browse files Browse the repository at this point in the history
Smarter handling of the profile `path` argument
  • Loading branch information
jwills authored Apr 27, 2023
2 parents 4ed698e + c7768da commit 35e39ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dbt/adapters/duckdb/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.5.0rc1"
version = "1.5.0rc1"
13 changes: 12 additions & 1 deletion dbt/adapters/duckdb/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
from typing import List
from typing import Optional
from typing import Tuple
from urllib.parse import urlparse

import duckdb

import dbt.exceptions
from dbt.adapters.base import Credentials
from dbt.dataclass_schema import dbtClassMixin

Expand Down Expand Up @@ -122,7 +124,16 @@ def __pre_deserialize__(cls, data: Dict[Any, Any]) -> Dict[Any, Any]:
if path == ":memory:":
data["database"] = "memory"
else:
data["database"] = os.path.splitext(os.path.basename(path))[0]
parsed = urlparse(path)
base_file = os.path.basename(parsed.path)
db = os.path.splitext(base_file)[0]
if db:
data["database"] = db
else:
raise dbt.exceptions.DbtRuntimeError(
"Unable to determine database name from path"
" and no database was specified in profile"
)
return data

@property
Expand Down

0 comments on commit 35e39ad

Please sign in to comment.