From 0c96ab97ba3695a75c4c4d91255c82b4306d5aa3 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Mon, 23 Dec 2024 19:54:52 +0800 Subject: [PATCH] fix udf Signed-off-by: Runji Wang --- src/binder/create_function.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/binder/create_function.rs b/src/binder/create_function.rs index 7cb4c1ba..c9fe3c38 100644 --- a/src/binder/create_function.rs +++ b/src/binder/create_function.rs @@ -85,7 +85,11 @@ impl Binder { // and double dollar (i.e., as $$select $1 + $2$$) for as clause let body = match function_body { Some(CreateFunctionBody::AsBeforeOptions(expr)) - | Some(CreateFunctionBody::AsAfterOptions(expr)) => expr.to_string(), + | Some(CreateFunctionBody::AsAfterOptions(expr)) => match expr { + Expr::Value(Value::SingleQuotedString(s)) => s, + Expr::Value(Value::DollarQuotedString(s)) => s.value, + _ => return Err(BindError::BindFunctionError("expected string".into())), + }, Some(CreateFunctionBody::Return(return_expr)) => { // Note: this is a current work around, and we are assuming return sql udf // will NOT involve complex syntax, so just reuse the logic for select definition