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

bug: cannot build Rust UDF #18797

Closed
stdrc opened this issue Oct 7, 2024 · 3 comments · Fixed by arrow-udf/arrow-udf#74 or #18862
Closed

bug: cannot build Rust UDF #18797

stdrc opened this issue Oct 7, 2024 · 3 comments · Fixed by arrow-udf/arrow-udf#74 or #18862
Labels
type/bug Something isn't working
Milestone

Comments

@stdrc
Copy link
Member

stdrc commented Oct 7, 2024

On current main (ef8c50f), Rust UDF cannot be built.

dev=> CREATE FUNCTION sum_array(integer[]) RETURNS integer LANGUAGE rust AS $$
    fn sum_array(xs: &[i32]) -> i32 {
        xs.iter().sum()
    }
$$;

ERROR:  Failed to run the query

Caused by these errors (recent errors listed first):
  1: failed to build rust function
  2: failed to build wasm (exit status: 101)
--- stdout

--- stderr
    Updating crates.io index
     Locking 3 packages to latest compatible versions
      Adding arrow-udf v0.3.0 (latest: v0.4.0)
      Adding arrow-udf-macros v0.3.0 (latest: v0.4.0)
      Adding lazy_static v1.5.0
   Compiling arrow-array v52.2.0
warning: the `wasm32-wasi` target is being renamed to `wasm32-wasip1` and the `wasm32-wasi` target will be removed from nightly in October 2024 and removed from stable Rust in January 2025

   Compiling arrow-select v52.2.0
   Compiling arrow-arith v52.2.0
   Compiling arrow-cast v52.2.0
warning: `arrow-array` (lib) generated 1 warning
   Compiling arrow-ipc v52.2.0
   Compiling arrow-udf v0.3.0
warning: `arrow-udf` (lib) generated 1 warning (1 duplicate)
warning: `arrow-select` (lib) generated 1 warning (1 duplicate)
warning: `arrow-ipc` (lib) generated 1 warning (1 duplicate)
warning: `arrow-arith` (lib) generated 1 warning (1 duplicate)
warning: `arrow-cast` (lib) generated 1 warning (1 duplicate)
   Compiling udf v0.1.0 (/private/var/folders/7r/p0w75cw53gj176x6_sxj7r8m0000gn/T/risingwave-rust-udf)
error[E0599]: no method named `as_primitive` found for struct `Arc<dyn arrow_array::array::Array>` in the current scope
   --> src/lib.rs:2:1
    |
2   | #[function("sum_array(int32[])->int32")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
   ::: /Users/richard/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arrow-array-52.2.0/src/cast.rs:750:8
    |
750 |     fn as_primitive<T: ArrowPrimitiveType>(&self) -> &PrimitiveArray<T> {
    |        ------------ the method is available for `Arc<dyn arrow_array::array::Array>` here
    |
    = help: items from traits can only be used if the trait is in scope
    = note: this error originates in the attribute macro `function` (in Nightly builds, run with -Z macro-backtrace for more info)
help: trait `AsArray` which provides `as_primitive` is implemented but not in scope; perhaps you want to import it
    |
1   + use arrow_udf::codegen::arrow_array::cast::AsArray;
    |
help: there is a method `as_primitive_opt` with a similar name
    |
2   | as_primitive_opt
    |

warning: unused import: `types`
 --> src/lib.rs:1:27
  |
1 | use arrow_udf::{function, types::*};
  |                           ^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

For more information about this error, try `rustc --explain E0599`.
warning: `udf` (lib) generated 2 warnings (1 duplicate)
error: could not compile `udf` (lib) due to 1 previous error; 2 warnings emitted

This is possibly because of upgrading arrow-udf in some previous PR.

@stdrc stdrc added the type/bug Something isn't working label Oct 7, 2024
@github-actions github-actions bot added this to the release-2.1 milestone Oct 7, 2024
wangrunji0408 pushed a commit to arrow-udf/arrow-udf that referenced this issue Oct 8, 2024
@BugenZhao
Copy link
Member

BugenZhao commented Oct 9, 2024

Don't we have any end-to-end tests covering such minimal usage? 🥵

@stdrc
Copy link
Member Author

stdrc commented Oct 11, 2024

Don't we have any end-to-end tests covering such minimal usage? 🥵

Interesting... We do have e2e tests for embedded UDFs:

echo "--- e2e, $mode, embedded udf"
python3 -m pip install --break-system-packages flask waitress
sqllogictest -p 4566 -d dev './e2e_test/udf/wasm_udf.slt'
sqllogictest -p 4566 -d dev './e2e_test/udf/rust_udf.slt'
sqllogictest -p 4566 -d dev './e2e_test/udf/js_udf.slt'
sqllogictest -p 4566 -d dev './e2e_test/udf/python_udf.slt'

Not sure why they didn't fail.

@stdrc
Copy link
Member Author

stdrc commented Oct 11, 2024

Don't we have any end-to-end tests covering such minimal usage? 🥵

I realized that this only fails when there's array type in function arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
2 participants