@@ -273,13 +273,17 @@ def execute_command(
273273 )
274274 )
275275
276+ # Determine format and disposition based on use_cloud_fetch
277+ format = "ARROW_STREAM" if use_cloud_fetch else "JSON_ARRAY"
278+ disposition = "EXTERNAL_LINKS" if use_cloud_fetch else "INLINE"
279+
276280 # Create the request model
277281 request = ExecuteStatementRequest (
278282 warehouse_id = self .warehouse_id ,
279283 session_id = sea_session_id ,
280284 statement = operation ,
281- disposition = "EXTERNAL_LINKS" if use_cloud_fetch else "INLINE" ,
282- format = "ARROW_STREAM" if use_cloud_fetch else "JSON_ARRAY" ,
285+ disposition = disposition ,
286+ format = format ,
283287 wait_timeout = "0s" if async_op else "30s" ,
284288 on_wait_timeout = "CONTINUE" ,
285289 row_limit = max_rows if max_rows > 0 else None ,
@@ -315,7 +319,7 @@ def execute_command(
315319 state = status .state
316320
317321 # Keep polling until we reach a terminal state
318- while state in [" PENDING" , " RUNNING" ]:
322+ while state in [CommandState . PENDING , CommandState . RUNNING ]:
319323 # Add a small delay to avoid excessive API calls
320324 time .sleep (0.5 )
321325
@@ -337,12 +341,12 @@ def execute_command(
337341 state = status .state
338342
339343 # Check for errors
340- if state == " FAILED" and status .error :
341- error_message = status .error [ " message" ]
344+ if state == CommandState . FAILED and status .error :
345+ error_message = status .error . message
342346 raise Error (f"Statement execution failed: { error_message } " )
343347
344348 # Check for cancellation
345- if state == "CANCELED" :
349+ if state == CommandState . CANCELLED :
346350 raise Error ("Statement execution was canceled" )
347351
348352 # Get the final result
@@ -435,11 +439,8 @@ def get_query_state(self, command_id: CommandId) -> CommandState:
435439 # Parse the response
436440 response = GetStatementResponse .from_dict (response_data )
437441
438- # Extract the status
439- state = response .status .state
440-
441- # Map SEA state to CommandState
442- return CommandState .from_sea_state (state )
442+ # Return the state directly since it's already a CommandState
443+ return response .status .state
443444
444445 def get_execution_result (
445446 self ,
@@ -591,20 +592,20 @@ def get_columns(
591592 table_name : Optional [str ] = None ,
592593 column_name : Optional [str ] = None ,
593594 ) -> "ResultSet" :
594- """Get columns by executing 'DESCRIBE TABLE [catalog.schema.]table '."""
595- if not table_name :
596- raise ValueError ("Table name is required for get_columns" )
595+ """Get columns by executing 'SHOW COLUMNS IN catalog [SCHEMA LIKE pattern] [ TABLE LIKE pattern] [LIKE pattern] '."""
596+ if not catalog_name :
597+ raise ValueError ("Catalog name is required for get_columns" )
597598
598- operation = "DESCRIBE TABLE "
599+ operation = f"SHOW COLUMNS IN ` { catalog_name } ` "
599600
600- if catalog_name and schema_name :
601- operation += f"`{ catalog_name } `.`{ schema_name } `."
602- elif schema_name :
603- operation += f"`{ schema_name } `."
601+ if schema_name :
602+ operation += f" SCHEMA LIKE '{ schema_name } '"
604603
605- operation += f"`{ table_name } `"
604+ if table_name :
605+ operation += f" TABLE LIKE '{ table_name } '"
606606
607- # Column name filtering will be done client-side
607+ if column_name :
608+ operation += f" LIKE '{ column_name } '"
608609
609610 result = self .execute_command (
610611 operation = operation ,
0 commit comments