Skip to content

Commit edc6893

Browse files
committed
Fix UDF return values
1 parent 9dc5832 commit edc6893

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

singlestoredb/functions/signature.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,13 +1023,17 @@ def signature_to_sql(
10231023

10241024
returns = ''
10251025
if signature.get('returns'):
1026-
prefix = 'RECORD('
1026+
ret = signature['returns']
10271027
if function_type == 'tvf':
1028-
prefix = 'TABLE('
1029-
res = prefix + ', '.join(
1030-
f'{escape_name(x["name"])} {x["sql"]}'
1031-
for x in signature['returns']
1032-
) + ')'
1028+
res = 'TABLE(' + ', '.join(
1029+
f'{escape_name(x["name"])} {x["sql"]}' for x in ret
1030+
) + ')'
1031+
elif ret[0]['name']:
1032+
res = 'RECORD(' + ', '.join(
1033+
f'{escape_name(x["name"])} {x["sql"]}' for x in ret
1034+
) + ')'
1035+
else:
1036+
res = ret[0]['sql']
10331037
returns = f' RETURNS {res}'
10341038

10351039
host = os.environ.get('SINGLESTOREDB_EXT_HOST', '127.0.0.1')

0 commit comments

Comments
 (0)