-
Notifications
You must be signed in to change notification settings - Fork 590
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): support inlined Rust UDF #14903
Conversation
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
This is amazing!
Should we consider including it into the Docker image? |
body = Some(function_body.clone()); | ||
|
||
let wasm_binary = | ||
tokio::task::spawn_blocking(move || arrow_udf_wasm::build("", &script)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, this means that we don't support specifying external crate dependencies now. This sounds good as the build.rs
could run arbitrary code and is quite unsafe in a managed environment.
I'm considering whether it's possible to support a whitelist of 3rd-party crates in the future, just like how Rust's online playground does: https://arc.net/l/quote/qtopwevk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or if wasm
can serve as a with-host-tools toolchain in the distant future... 🤣
https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-2-with-host-tools
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm considering whether it's possible to support a whitelist of 3rd-party crates in the future, just like how Rust's online playground does: https://arc.net/l/quote/qtopwevk
Good idea! We can follow their way: pre-download all the crates that Rust playground supports and add --offline
to cargo build
.
body = Some(function_body.clone()); | ||
|
||
let wasm_binary = | ||
tokio::task::spawn_blocking(move || arrow_udf_wasm::build("", &script)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The experimental feature of cargo script would also be helpful: rust-lang/cargo#12207
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I have investigated it. But cargo script
seems to only support executables, not libraries. 😕
let system_params = session.env().meta_client().get_system_params().await?; | ||
let object_name = format!("{:?}.wasm", md5::compute(&wasm_binary)); | ||
upload_wasm_binary( | ||
system_params.wasm_storage_url(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we still going to deprecate the external storage for WASM binaries? I'm not sure if a Rust WASM binary fits the metadata store. 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "yes"? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will soon move WASM binaries from object store to meta store. I think meta store is capable given that we will move to SQL backend soon and binaries usually won't be larger than 10MB. 😄
Can we detect the existance of the toolchain before building? Seems in this PR the query will run for a while before reporting missing
Is it possible to print some notice before building or make it run in background? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks so successful to me!
Signed-off-by: Runji Wang <[email protected]>
Signed-off-by: Runji Wang <[email protected]>
Sure. I've added a feature to automatically install the target on build if |
I did a quick investigation and found |
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
This PR allows users to inline their Rust UDF code in the create-function statement.
The function will be built into a wasm binary in the frontend. This requires the Rust toolchain (with the wasm32-wasi target) installed in frontend's environment. The build process will run for at least 10s, during which time the command is blocking from user's perspective. It may also require network access to download dependencies. Therefore, in the future we should consider how to:
Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
Add support for inline Rust UDFs.