File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
singlestoredb/functions/ext Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -319,11 +319,17 @@ async def do_func(
319319 row_ids = array_cls (row_ids )
320320
321321 # Call the function with `cols` as the function parameters
322+ is_async = inspect .iscoroutinefunction (func ) or inspect .iscoroutinefunction (getattr (func , "__wrapped__" , None ))
322323 if cols and cols [0 ]:
323- out = func (* [x if m else x [0 ] for x , m in zip (cols , masks )])
324- else :
325- out = func ()
326-
324+ if is_async :
325+ out = await func (* [x if m else x [0 ] for x , m in zip (cols , masks )])
326+ else :
327+ out = await asyncio .to_thread (func , * [x if m else x [0 ] for x , m in zip (cols , masks )])
328+ if is_async :
329+ out = await func ()
330+ else :
331+ out = await asyncio .to_thread (func ())
332+
327333 # Single masked value
328334 if isinstance (out , Masked ):
329335 return row_ids , [tuple (out )]
You can’t perform that action at this time.
0 commit comments