Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [
]
dependencies = [
"ibis-framework>=10.0,<11",
"hotdata>=0.2.3",
"hotdata>=0.2.4",
"pyarrow>=15",
"pyarrow-hotfix>=0.6",
"pandas>=2",
Expand Down
12 changes: 6 additions & 6 deletions src/ibis_hotdata/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def _resolve_connection(self, name_or_id: str) -> dict[str, Any]:
raise com.IbisError(f"Unknown Hotdata connection {name_or_id!r}")

def _find_managed_connection(self, name_or_id: str) -> dict[str, Any] | None:
"""Look up a managed database by id or description.
"""Look up a managed database by id or name.

Returns the detail dict if found, ``None`` if not found.
Raises :class:`~ibis.common.exceptions.IbisError` on API failures.
Expand All @@ -347,21 +347,21 @@ def _find_managed_connection(self, name_or_id: str) -> dict[str, Any] | None:
except HotdataAPIError as exc:
if exc.status_code != 404:
raise _ibis_err_from_hotdata(exc) from exc
# Fall back to description scan
# Fall back to name scan
try:
data = self._http.list_databases()
except HotdataAPIError as exc:
raise _ibis_err_from_hotdata(exc) from exc
for db in data.get("databases", []):
if db.get("description") == name_or_id:
if db.get("name") == name_or_id:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: (not blocking) several nearby comments/docstrings still describe the lookup as "by id or description" or "Fall back to description scan" (lines 340, 350, 364, 588). Worth updating the prose to match the renamed field.

try:
return self._http.get_database(db["id"])
except HotdataAPIError as exc:
raise _ibis_err_from_hotdata(exc) from exc
return None

def _resolve_managed_connection(self, name_or_id: str) -> dict[str, Any]:
"""Resolve a managed database by id or description, returning its detail dict."""
"""Resolve a managed database by id or name, returning its detail dict."""
result = self._find_managed_connection(name_or_id)
if result is None:
raise com.IbisError(f"Unknown managed database {name_or_id!r}")
Expand Down Expand Up @@ -585,7 +585,7 @@ def create_database(
raise com.UnsupportedOperationError(
"Hotdata create_database creates a managed connection (catalog); catalog= is not supported"
)
# Check if a database with this description already exists.
# Check if a database with this name already exists.
# Use _find_managed_connection so API errors (5xx) propagate while
# a plain not-found returns None and is handled below.
existing = self._find_managed_connection(name)
Expand All @@ -594,7 +594,7 @@ def create_database(
raise com.IbisInputError(f"Managed database {name!r} already exists")
return
try:
self._http.create_managed_database(description=name, schema=schema, tables=list(tables or ()))
self._http.create_managed_database(name=name, schema=schema, tables=list(tables or ()))
except HotdataAPIError as exc:
raise _ibis_err_from_hotdata(exc) from exc

Expand Down
4 changes: 2 additions & 2 deletions src/ibis_hotdata/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def get_database(self, database_id: str) -> dict[str, Any]:

def create_managed_database(
self,
description: str | None = None,
name: str | None = None,
*,
schema: str = "public",
tables: Sequence[str] = (),
Expand All @@ -209,7 +209,7 @@ def create_managed_database(
tables=[DatabaseDefaultTableDecl(name=t) for t in tables],
)
]
req = CreateDatabaseRequest(description=description, schemas=schemas)
req = CreateDatabaseRequest(name=name, schemas=schemas)
resp = self._safe_call(self._databases.create_database, req)
return resp.model_dump(by_alias=True, mode="json")

Expand Down
12 changes: 6 additions & 6 deletions tests/test_hotdata_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def managed_databases_response() -> dict:
"databases": [
{
"id": MANAGED_DB_ID,
"description": MANAGED_NAME,
"name": MANAGED_NAME,
}
]
}
Expand All @@ -57,7 +57,7 @@ def managed_databases_response() -> dict:
def managed_database_detail_response() -> dict:
return {
"id": MANAGED_DB_ID,
"description": MANAGED_NAME,
"name": MANAGED_NAME,
"default_connection_id": MANAGED_CONN,
"expires_at": None,
"attachments": [],
Expand Down Expand Up @@ -483,14 +483,14 @@ def test_create_database_posts_managed_connection(httpserver: HTTPServer, srv: s
def on_create(req: Request) -> Response:
body = req.get_json()
assert body == {
"description": "sales",
"name": "sales",
"schemas": [{"name": "public", "tables": [{"name": "orders"}]}],
}
return Response(
json.dumps(
{
"id": MANAGED_DB_ID,
"description": "sales",
"name": "sales",
"default_connection_id": MANAGED_CONN,
"expires_at": None,
}
Expand All @@ -513,13 +513,13 @@ def on_create(req: Request) -> Response:
def test_create_database_sends_no_schemas_when_no_tables(httpserver: HTTPServer, srv: str):
def on_create(req: Request) -> Response:
body = req.get_json()
assert body.get("description") == "empty_db"
assert body.get("name") == "empty_db"
assert not body.get("schemas") # no tables → no schemas declared
return Response(
json.dumps(
{
"id": MANAGED_DB_ID,
"description": "empty_db",
"name": "empty_db",
"default_connection_id": MANAGED_CONN,
"expires_at": None,
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_hotdata_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ def test_create_managed_database(httpserver: HTTPServer):
def on_create(req: Request) -> Response:
body = req.get_json()
assert body == {
"description": "sales",
"name": "sales",
"schemas": [{"name": "public", "tables": [{"name": "orders"}]}],
}
return Response(
json.dumps(
{
"id": "db_sales",
"description": "sales",
"name": "sales",
"default_connection_id": "conn_sales",
"expires_at": None,
}
Expand Down
10 changes: 5 additions & 5 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading