From b902d6103e4ea1db533fe4ace088a15e0da0562c Mon Sep 17 00:00:00 2001 From: Richard Chien Date: Fri, 11 Oct 2024 14:19:12 +0800 Subject: [PATCH 1/3] upgrade arrow-udf to 0.5 Signed-off-by: Richard Chien --- e2e_test/udf/wasm/Cargo.toml | 2 +- src/expr/impl/src/udf/wasm.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e_test/udf/wasm/Cargo.toml b/e2e_test/udf/wasm/Cargo.toml index 4f6b109aa421a..ce957389ca314 100644 --- a/e2e_test/udf/wasm/Cargo.toml +++ b/e2e_test/udf/wasm/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -arrow-udf = "0.4" +arrow-udf = "0.5" genawaiter = "0.99" rust_decimal = "1" serde_json = "1" diff --git a/src/expr/impl/src/udf/wasm.rs b/src/expr/impl/src/udf/wasm.rs index 5a0dd0420b4d9..6b4a810eb3d58 100644 --- a/src/expr/impl/src/udf/wasm.rs +++ b/src/expr/impl/src/udf/wasm.rs @@ -92,7 +92,7 @@ fn create_rust(opts: CreateFunctionOptions<'_>) -> Result let wasm_binary = std::thread::spawn(move || { let mut opts = arrow_udf_wasm::build::BuildOpts::default(); - opts.arrow_udf_version = Some("0.3".to_string()); + opts.arrow_udf_version = Some("0.5".to_string()); opts.script = script; // use a fixed tempdir to reuse the build cache opts.tempdir = Some(std::env::temp_dir().join("risingwave-rust-udf")); From d434b92e249d851539472421496f6480492a9312 Mon Sep 17 00:00:00 2001 From: Richard Chien Date: Fri, 11 Oct 2024 14:19:17 +0800 Subject: [PATCH 2/3] minor Signed-off-by: Richard Chien --- ci/scripts/build-other.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/scripts/build-other.sh b/ci/scripts/build-other.sh index d59e8ea876ccf..70adf10a8f7fd 100755 --- a/ci/scripts/build-other.sh +++ b/ci/scripts/build-other.sh @@ -8,7 +8,7 @@ source ci/scripts/common.sh echo "--- Build Rust UDF" cd e2e_test/udf/wasm rustup target add wasm32-wasi -cargo build --release +cargo build --release --target wasm32-wasi cd ../../.. echo "--- Build Java packages" From aac567f34af030de4f85791eddb87a0d22457717 Mon Sep 17 00:00:00 2001 From: Richard Chien Date: Fri, 11 Oct 2024 15:23:24 +0800 Subject: [PATCH 3/3] add e2e Signed-off-by: Richard Chien --- e2e_test/udf/rust_udf.slt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/e2e_test/udf/rust_udf.slt b/e2e_test/udf/rust_udf.slt index 6f84ba1cdea43..7eeeb60a4a4ee 100644 --- a/e2e_test/udf/rust_udf.slt +++ b/e2e_test/udf/rust_udf.slt @@ -148,6 +148,23 @@ select series(3); statement ok drop function series; + +statement ok +create function sum_array(integer[]) returns integer language rust as $$ + fn sum_array(xs: &[i32]) -> i32 { + xs.iter().sum() + } +$$; + +query I +select sum_array(array[1, 2, 3]); +---- +6 + +statement ok +drop function sum_array; + + # XXX: this test is disabled in CI because it prints "panicked at" which makes the test fail # statement ok # create function panic() returns int language rust as $$