@@ -220,41 +220,56 @@ async def _do_execute(
220220 ) -> None :
221221 await self ._close_rowset_and_reset ()
222222 self ._row_set = StreamingAsyncRowSet () if streaming else InMemoryAsyncRowSet ()
223+
223224 # Import paramstyle from module level
224225 from firebolt .async_db import paramstyle
225226
226227 try :
227228 parameter_style = ParameterStyle (paramstyle )
228229 except ValueError :
229230 raise ProgrammingError (f"Unsupported paramstyle: { paramstyle } " )
231+
232+ # Validate bulk_insert parameter early
233+ if bulk_insert and parameter_style != ParameterStyle .FB_NUMERIC :
234+ raise ConfigurationError ("bulk_insert is only supported for fb_numeric" )
235+
230236 try :
237+ # Handle FB_NUMERIC parameter style
231238 if parameter_style == ParameterStyle .FB_NUMERIC :
232- if bulk_insert :
233- raw_query , parameters = self ._prepare_bulk_insert (
234- raw_query , parameters
235- )
239+ processed_query , processed_params = (
240+ self ._prepare_bulk_insert (raw_query , parameters )
241+ if bulk_insert
242+ else (raw_query , parameters )
243+ )
236244 await self ._execute_fb_numeric (
237- raw_query , parameters , timeout , async_execution , streaming
245+ processed_query ,
246+ processed_params ,
247+ timeout ,
248+ async_execution ,
249+ streaming ,
238250 )
239- else :
240- if bulk_insert :
241- raise ConfigurationError (
242- "bulk_insert is only supported for fb_numeric"
243- )
244- queries : List [Union [SetParameter , str ]] = (
245- [raw_query ]
246- if skip_parsing
247- else self ._formatter .split_format_sql (raw_query , parameters )
251+ self ._state = CursorState .DONE
252+ return
253+
254+ # Handle other parameter styles
255+ queries = (
256+ [raw_query ]
257+ if skip_parsing
258+ else self ._formatter .split_format_sql (raw_query , parameters )
259+ )
260+
261+ # Validate async execution with multi-statement queries early
262+ if len (queries ) > 1 and async_execution :
263+ raise FireboltError (
264+ "Server side async does not support multi-statement queries"
248265 )
249- timeout_controller = TimeoutController (timeout )
250- if len (queries ) > 1 and async_execution :
251- raise FireboltError (
252- "Server side async does not support multi-statement queries"
253- )
254- for query in queries :
255- await self ._execute_single_query (
256- query , timeout_controller , async_execution , streaming
257- )
266+
267+ timeout_controller = TimeoutController (timeout )
268+ for query in queries :
269+ await self ._execute_single_query (
270+ query , timeout_controller , async_execution , streaming
271+ )
272+
258273 self ._state = CursorState .DONE
259274 except Exception :
260275 self ._state = CursorState .ERROR
0 commit comments