Skip to content

Commit 339aa96

Browse files
Merge branch 'users/kaushik/udf-idle-start-fix' of github.com:kkampli-singlestore/singlestoredb-python into users/kaushik/udfs-temp
2 parents aa1b8ed + a01f9ae commit 339aa96

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

singlestoredb/apps/_python_udfs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
async def run_udf_app(
18-
replace_existing: bool,
1918
log_level: str = 'error',
2019
kill_existing_app_server: bool = True,
2120
) -> UdfConnectionInfo:
@@ -55,8 +54,9 @@ async def run_udf_app(
5554
)
5655
_running_server = AwaitableUvicornServer(config)
5756

58-
# Register the functions
59-
app.register_functions(replace=replace_existing)
57+
# Register the functions only if the app is running interactively.
58+
if app_config.running_interactively:
59+
app.register_functions(replace=True)
6060

6161
asyncio.create_task(_running_server.serve())
6262
await _running_server.wait_for_startup()

singlestoredb/functions/ext/asgi.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,13 @@ def get_function_info(
12001200
functions = {}
12011201
no_default = object()
12021202

1203+
# Generate CREATE FUNCTION SQL for each function using get_create_functions
1204+
create_sqls = self.get_create_functions(replace=True)
1205+
sql_map = {}
1206+
for (_, info), sql in zip(self.endpoints.values(), create_sqls):
1207+
sig = info['signature']
1208+
sql_map[sig['name']] = sql
1209+
12031210
for key, (_, info) in self.endpoints.items():
12041211
if not func_name or key == func_name:
12051212
sig = info['signature']
@@ -1237,8 +1244,12 @@ def get_function_info(
12371244
if a.get('default', no_default) is not no_default:
12381245
returns[-1]['default'] = a['default']
12391246

1247+
sql = sql_map.get(sig['name'], '')
12401248
functions[sig['name']] = dict(
1241-
args=args, returns=returns, function_type=info['function_type'],
1249+
args=args,
1250+
returns=returns,
1251+
function_type=info['function_type'],
1252+
sql_statement=sql,
12421253
)
12431254

12441255
return functions

0 commit comments

Comments
 (0)