Skip to content

Commit e8745f5

Browse files
import cancel udf changes
1 parent 42313b0 commit e8745f5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

singlestoredb/functions/ext/asgi.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ def build_vector_udf_endpoint(
307307
"""
308308
masks = get_masked_params(func)
309309
array_cls = get_array_class(returns_data_format)
310+
is_async = asyncio.iscoroutinefunction(func)
310311

311312
async def do_func(
312313
row_ids: Sequence[int],
@@ -319,15 +320,16 @@ async def do_func(
319320
row_ids = array_cls(row_ids)
320321

321322
# Call the function with `cols` as the function parameters
322-
is_async = inspect.iscoroutinefunction(func) or inspect.iscoroutinefunction(getattr(func, "__wrapped__", None))
323-
if is_async:
324-
out = await func(*[x if m else x[0] for x, m in zip(cols, masks)])
323+
if cols and cols[0]:
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 = func(*[x if m else x[0] for x, m in zip(cols, masks)])
325328
else:
326-
out = await asyncio.to_thread(func, *[x if m else x[0] for x, m in zip(cols, masks)])
327-
328-
# Single masked value
329-
if isinstance(out, Masked):
330-
return row_ids, [tuple(out)]
329+
if is_async:
330+
out = await func()
331+
else:
332+
out = func()
331333

332334
# Multiple return values
333335
if isinstance(out, tuple):

0 commit comments

Comments
 (0)