Skip to content

Commit

Permalink
fix(query): fix wasm udf runtime create with code (#16191)
Browse files Browse the repository at this point in the history
  • Loading branch information
b41sh authored Aug 6, 2024
1 parent 812688f commit feae7e3
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub enum ScriptRuntime {
impl ScriptRuntime {
pub fn try_create(
lang: &str,
code: Option<Vec<u8>>,
code: Option<&[u8]>,
runtime_num: usize,
) -> Result<Self, ErrorCode> {
match lang {
Expand Down Expand Up @@ -87,11 +87,11 @@ impl ScriptRuntime {
}
}

fn create_wasm_runtime(code_blob: Option<Vec<u8>>) -> Result<Self, ErrorCode> {
fn create_wasm_runtime(code_blob: Option<&[u8]>) -> Result<Self, ErrorCode> {
let decoded_code_blob = code_blob
.ok_or_else(|| ErrorCode::UDFDataError("WASM module not provided".to_string()))?;

let runtime = arrow_udf_wasm::Runtime::new(&decoded_code_blob).map_err(|err| {
let runtime = arrow_udf_wasm::Runtime::new(decoded_code_blob).map_err(|err| {
ErrorCode::UDFDataError(format!("Failed to create WASM runtime for module: {}", err))
})?;

Expand Down Expand Up @@ -277,7 +277,7 @@ impl TransformUdfScript {
let start = std::time::Instant::now();
for func in funcs {
let (lang, code_opt) = match &func.udf_type {
UDFType::Script((lang, _, _code)) => (lang, None),
UDFType::Script((lang, _, code)) => (lang, Some(code.as_ref())),
_ => continue,
};

Expand Down

0 comments on commit feae7e3

Please sign in to comment.