Skip to content

Commit 93a0018

Browse files
Merge pull request #69 from kkampli-singlestore/users/kaushik/udf-idle-start-fix
[backend:improvement] Add SQL registration Statements in UDF base URL response
2 parents 45cf138 + a01f9ae commit 93a0018

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
@@ -964,6 +964,13 @@ def get_function_info(
964964
functions = {}
965965
no_default = object()
966966

967+
# Generate CREATE FUNCTION SQL for each function using get_create_functions
968+
create_sqls = self.get_create_functions(replace=True)
969+
sql_map = {}
970+
for (_, info), sql in zip(self.endpoints.values(), create_sqls):
971+
sig = info['signature']
972+
sql_map[sig['name']] = sql
973+
967974
for key, (_, info) in self.endpoints.items():
968975
if not func_name or key == func_name:
969976
sig = info['signature']
@@ -1001,8 +1008,12 @@ def get_function_info(
10011008
if a.get('default', no_default) is not no_default:
10021009
returns[-1]['default'] = a['default']
10031010

1011+
sql = sql_map.get(sig['name'], '')
10041012
functions[sig['name']] = dict(
1005-
args=args, returns=returns, function_type=info['function_type'],
1013+
args=args,
1014+
returns=returns,
1015+
function_type=info['function_type'],
1016+
sql_statement=sql,
10061017
)
10071018

10081019
return functions

0 commit comments

Comments
 (0)