File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
singlestoredb/functions/ext Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -319,11 +319,18 @@ 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+ 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 )])
324328 else :
325- out = func ()
326-
329+ if is_async :
330+ out = await func ()
331+ else :
332+ out = await asyncio .to_thread (func ())
333+
327334 # Single masked value
328335 if isinstance (out , Masked ):
329336 return row_ids , [tuple (out )]
You can’t perform that action at this time.
0 commit comments