@@ -101,7 +101,6 @@ def _extract_warehouse_id(self, http_path: str) -> str:
101
101
102
102
The warehouse ID is expected to be the last segment of the path when the
103
103
second-to-last segment is either 'warehouses' or 'endpoints'.
104
- This matches the JDBC implementation which supports both formats.
105
104
106
105
Args:
107
106
http_path: The HTTP path from which to extract the warehouse ID
@@ -182,7 +181,6 @@ def open_session(
182
181
schema = schema ,
183
182
)
184
183
185
- # Send the request
186
184
response = self .http_client ._make_request (
187
185
method = "POST" , path = self .SESSION_PATH , data = request .to_dict ()
188
186
)
@@ -219,16 +217,14 @@ def close_session(self, session_id: SessionId) -> None:
219
217
raise ValueError ("Not a valid SEA session ID" )
220
218
sea_session_id = session_id .to_sea_session_id ()
221
219
222
- # Create the request model
223
220
request = DeleteSessionRequest (
224
221
warehouse_id = self .warehouse_id , session_id = sea_session_id
225
222
)
226
223
227
- # Send the request
228
224
self .http_client ._make_request (
229
225
method = "DELETE" ,
230
226
path = self .SESSION_PATH_WITH_ID .format (sea_session_id ),
231
- data = request .to_dict (),
227
+ params = request .to_dict (),
232
228
)
233
229
234
230
def execute_command (
@@ -279,11 +275,8 @@ def execute_command(
279
275
)
280
276
)
281
277
282
- # Determine format and disposition based on use_cloud_fetch
283
278
format = "ARROW_STREAM" if use_cloud_fetch else "JSON_ARRAY"
284
279
disposition = "EXTERNAL_LINKS" if use_cloud_fetch else "INLINE"
285
-
286
- # Create the request model
287
280
request = ExecuteStatementRequest (
288
281
warehouse_id = self .warehouse_id ,
289
282
session_id = sea_session_id ,
@@ -297,15 +290,10 @@ def execute_command(
297
290
parameters = sea_parameters if sea_parameters else None ,
298
291
)
299
292
300
- # Execute the statement
301
293
response_data = self .http_client ._make_request (
302
294
method = "POST" , path = self .STATEMENT_PATH , data = request .to_dict ()
303
295
)
304
-
305
- # Parse the response
306
296
response = ExecuteStatementResponse .from_dict (response_data )
307
-
308
- # Create a command ID from the statement ID
309
297
statement_id = response .statement_id
310
298
if not statement_id :
311
299
raise ServerOperationError (
@@ -344,7 +332,6 @@ def execute_command(
344
332
},
345
333
)
346
334
347
- # Get the final result
348
335
return self .get_execution_result (command_id , cursor )
349
336
350
337
def cancel_command (self , command_id : CommandId ) -> None :
@@ -362,10 +349,7 @@ def cancel_command(self, command_id: CommandId) -> None:
362
349
363
350
sea_statement_id = command_id .to_sea_statement_id ()
364
351
365
- # Create the request model
366
352
request = CancelStatementRequest (statement_id = sea_statement_id )
367
-
368
- # Send the cancel request
369
353
self .http_client ._make_request (
370
354
method = "POST" ,
371
355
path = self .CANCEL_STATEMENT_PATH_WITH_ID .format (sea_statement_id ),
@@ -387,10 +371,7 @@ def close_command(self, command_id: CommandId) -> None:
387
371
388
372
sea_statement_id = command_id .to_sea_statement_id ()
389
373
390
- # Create the request model
391
374
request = CloseStatementRequest (statement_id = sea_statement_id )
392
-
393
- # Send the close request - SEA uses DELETE for closing statements
394
375
self .http_client ._make_request (
395
376
method = "DELETE" ,
396
377
path = self .STATEMENT_PATH_WITH_ID .format (sea_statement_id ),
@@ -415,10 +396,7 @@ def get_query_state(self, command_id: CommandId) -> CommandState:
415
396
416
397
sea_statement_id = command_id .to_sea_statement_id ()
417
398
418
- # Create the request model
419
399
request = GetStatementRequest (statement_id = sea_statement_id )
420
-
421
- # Get the statement status
422
400
response_data = self .http_client ._make_request (
423
401
method = "GET" ,
424
402
path = self .STATEMENT_PATH_WITH_ID .format (sea_statement_id ),
@@ -427,8 +405,6 @@ def get_query_state(self, command_id: CommandId) -> CommandState:
427
405
428
406
# Parse the response
429
407
response = GetStatementResponse .from_dict (response_data )
430
-
431
- # Return the state directly since it's already a CommandState
432
408
return response .status .state
433
409
434
410
def get_execution_result (
@@ -509,10 +485,12 @@ def get_schemas(
509
485
catalog_name : Optional [str ] = None ,
510
486
schema_name : Optional [str ] = None ,
511
487
) -> "ResultSet" :
512
- """Get schemas by executing 'SHOW SCHEMAS [IN catalog]'."""
513
- operation = "SHOW SCHEMAS"
514
- if catalog_name :
515
- operation += f" IN `{ catalog_name } `"
488
+ """Get schemas by executing 'SHOW SCHEMAS IN catalog [LIKE pattern]'."""
489
+ if not catalog_name :
490
+ raise ValueError ("Catalog name is required for get_schemas" )
491
+
492
+ operation = f"SHOW SCHEMAS IN `{ catalog_name } `"
493
+
516
494
if schema_name :
517
495
operation += f" LIKE '{ schema_name } '"
518
496
@@ -542,13 +520,18 @@ def get_tables(
542
520
table_name : Optional [str ] = None ,
543
521
table_types : Optional [List [str ]] = None ,
544
522
) -> "ResultSet" :
545
- """Get tables by executing 'SHOW TABLES [IN catalog.schema]'."""
546
- operation = "SHOW TABLES"
523
+ """Get tables by executing 'SHOW TABLES IN catalog [SCHEMA LIKE pattern] [LIKE pattern]'."""
524
+ if not catalog_name :
525
+ raise ValueError ("Catalog name is required for get_tables" )
526
+
527
+ operation = "SHOW TABLES IN " + (
528
+ "ALL CATALOGS"
529
+ if catalog_name in [None , "*" , "%" ]
530
+ else f"CATALOG `{ catalog_name } `"
531
+ )
547
532
548
- if catalog_name and schema_name :
549
- operation += f" IN `{ catalog_name } `.`{ schema_name } `"
550
- elif schema_name :
551
- operation += f" IN `{ schema_name } `"
533
+ if schema_name :
534
+ operation += f" SCHEMA LIKE '{ schema_name } '"
552
535
553
536
if table_name :
554
537
operation += f" LIKE '{ table_name } '"
@@ -579,11 +562,11 @@ def get_columns(
579
562
table_name : Optional [str ] = None ,
580
563
column_name : Optional [str ] = None ,
581
564
) -> "ResultSet" :
582
- """Get columns by executing 'SHOW COLUMNS IN catalog [SCHEMA LIKE pattern] [TABLE LIKE pattern] [LIKE pattern]'."""
565
+ """Get columns by executing 'SHOW COLUMNS IN CATALOG catalog [SCHEMA LIKE pattern] [TABLE LIKE pattern] [LIKE pattern]'."""
583
566
if not catalog_name :
584
567
raise ValueError ("Catalog name is required for get_columns" )
585
568
586
- operation = f"SHOW COLUMNS IN `{ catalog_name } `"
569
+ operation = f"SHOW COLUMNS IN CATALOG `{ catalog_name } `"
587
570
588
571
if schema_name :
589
572
operation += f" SCHEMA LIKE '{ schema_name } '"
0 commit comments