File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
singlestoredb/functions/ext Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,14 @@ async def do_func( # type: ignore
192192
193193 out_ids , out = [], []
194194 res = func (* [x [0 ] for x in cols ])
195+ rtype = str (type (res )).lower ()
196+
197+ # Map tables / dataframes to a list of columns
198+ if 'dataframe' in rtype :
199+ res = [res [x ] for x in res .columns ]
200+ elif 'table' in rtype :
201+ res = res .columns
202+
195203 for vec in res :
196204 # C extension only supports Python objects as strings
197205 if data_format == 'numpy' and str (vec .dtype )[:2 ] in ['<U' , '<S' ]:
@@ -239,9 +247,14 @@ async def do_func( # type: ignore
239247 out = func (* cols )
240248 assert isinstance (out , tuple )
241249 return row_ids , [out ]
250+
242251 out = func (* [x [0 ] for x in cols ])
252+
253+ # Multiple return values
243254 if isinstance (out , tuple ):
244255 return row_ids , [(x , None ) for x in out ]
256+
257+ # Single return value
245258 return row_ids , [(out , None )]
246259
247260 do_func .__name__ = name
You can’t perform that action at this time.
0 commit comments