3434 ManagedDatabase ,
3535 ManagedTable ,
3636 MANAGED_SOURCE_TYPE ,
37- _api_error ,
38- _managed_database ,
37+ api_error_message ,
3938 create_connection_request ,
4039 is_parquet_path ,
40+ managed_database_from_connection ,
4141)
4242from hotdata_runtime .http import default_http_retries
4343from hotdata_runtime .result import QueryResult
@@ -154,7 +154,7 @@ def uploads(self) -> UploadsApi:
154154 def list_managed_databases (self ) -> list [ManagedDatabase ]:
155155 listing = self .connections ().list_connections ()
156156 return [
157- _managed_database (c )
157+ managed_database_from_connection (c )
158158 for c in listing .connections
159159 if c .source_type == MANAGED_SOURCE_TYPE
160160 ]
@@ -173,7 +173,7 @@ def resolve_managed_database(self, name_or_id: str) -> ManagedDatabase:
173173 f"{ match .name !r} is not a managed database "
174174 f"(source_type: { match .source_type } )"
175175 )
176- return _managed_database (match )
176+ return managed_database_from_connection (match )
177177
178178 def create_managed_database (
179179 self ,
@@ -186,15 +186,15 @@ def create_managed_database(
186186 try :
187187 created = self .connections ().create_connection (request )
188188 except ApiException as e :
189- raise RuntimeError (_api_error (e )) from e
190- return _managed_database (created )
189+ raise RuntimeError (api_error_message (e )) from e
190+ return managed_database_from_connection (created )
191191
192192 def delete_managed_database (self , name_or_id : str ) -> None :
193193 db = self .resolve_managed_database (name_or_id )
194194 try :
195195 self .connections ().delete_connection (db .id )
196196 except ApiException as e :
197- raise RuntimeError (_api_error (e )) from e
197+ raise RuntimeError (api_error_message (e )) from e
198198
199199 def list_managed_tables (
200200 self ,
@@ -232,7 +232,7 @@ def upload_parquet(self, path: str) -> str:
232232 _content_type = "application/octet-stream" ,
233233 )
234234 except ApiException as e :
235- raise RuntimeError (_api_error (e )) from e
235+ raise RuntimeError (api_error_message (e )) from e
236236 return uploaded .id
237237
238238 def load_managed_table (
@@ -247,7 +247,11 @@ def load_managed_table(
247247 if (upload_id is None ) == (file is None ):
248248 raise ValueError ("Exactly one of upload_id or file is required" )
249249 db = self .resolve_managed_database (database )
250- resolved_upload_id = upload_id or self .upload_parquet (file or "" )
250+ if upload_id is not None :
251+ resolved_upload_id = upload_id
252+ else :
253+ assert file is not None
254+ resolved_upload_id = self .upload_parquet (file )
251255 request = LoadManagedTableRequest (
252256 mode = "replace" ,
253257 upload_id = resolved_upload_id ,
@@ -260,7 +264,7 @@ def load_managed_table(
260264 request ,
261265 )
262266 except ApiException as e :
263- raise RuntimeError (_api_error (e )) from e
267+ raise RuntimeError (api_error_message (e )) from e
264268 return LoadManagedTableResult (
265269 connection_id = loaded .connection_id ,
266270 schema_name = loaded .schema_name ,
@@ -280,7 +284,7 @@ def delete_managed_table(
280284 try :
281285 self .connections ().delete_managed_table (db .id , schema , table )
282286 except ApiException as e :
283- raise RuntimeError (_api_error (e )) from e
287+ raise RuntimeError (api_error_message (e )) from e
284288
285289 def list_recent_results (
286290 self ,
0 commit comments