Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(udf): add body field for udf body definition #14300

Merged
merged 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions proto/catalog.proto
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ message Function {
string language = 7;
string link = 8;
string identifier = 10;
string body = 14;

oneof kind {
ScalarFunction scalar = 11;
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/binder/expr/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl Binder {
if func.language == "sql" {
// This represents the current user defined function is `language sql`
let parse_result =
risingwave_sqlparser::parser::Parser::parse_sql(func.identifier.as_str());
risingwave_sqlparser::parser::Parser::parse_sql(func.body.as_str());
if let Err(ParserError::ParserError(err)) | Err(ParserError::TokenizerError(err)) =
parse_result
{
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/catalog/function_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct FunctionCatalog {
pub return_type: DataType,
pub language: String,
pub identifier: String,
pub body: String,
pub link: String,
}

Expand Down Expand Up @@ -63,6 +64,7 @@ impl From<&PbFunction> for FunctionCatalog {
return_type: prost.return_type.as_ref().expect("no return type").into(),
language: prost.language.clone(),
identifier: prost.identifier.clone(),
body: prost.body.clone(),
link: prost.link.clone(),
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/expr/user_defined_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ impl UserDefinedFunction {
return_type,
language: udf.get_language().clone(),
identifier: udf.get_identifier().clone(),
// TODO: Ensure if we need `body` here
body: "".to_string(),
link: udf.get_link().clone(),
};

Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/handler/create_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ pub async fn handle_create_function(
return_type: Some(return_type.into()),
language,
identifier,
body: "".to_string(),
link,
owner: session.user_id(),
};
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/handler/create_sql_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ pub async fn handle_create_sql_function(
arg_types: arg_types.into_iter().map(|t| t.into()).collect(),
return_type: Some(return_type.into()),
language,
identifier: body,
identifier: "".to_string(),
body,
link: "".to_string(),
owner: session.user_id(),
};
Expand Down
2 changes: 2 additions & 0 deletions src/meta/model_v2/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct Model {
pub language: String,
pub link: String,
pub identifier: String,
pub body: String,
xzhseh marked this conversation as resolved.
Show resolved Hide resolved
xzhseh marked this conversation as resolved.
Show resolved Hide resolved
pub kind: FunctionKind,
}

Expand Down Expand Up @@ -94,6 +95,7 @@ impl From<PbFunction> for ActiveModel {
language: Set(function.language),
link: Set(function.link),
identifier: Set(function.identifier),
body: Set(function.body),
kind: Set(function.kind.unwrap().into()),
}
}
Expand Down
1 change: 1 addition & 0 deletions src/meta/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ impl From<ObjectModel<function::Model>> for PbFunction {
language: value.0.language,
link: value.0.link,
identifier: value.0.identifier,
body: value.0.body,
kind: Some(value.0.kind.into()),
}
}
Expand Down
Loading