From c31d1d8b49a85f203692d4bb9e08f9af9f3918e9 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Thu, 30 May 2024 21:48:27 +0800 Subject: [PATCH] fix table function with no argument Signed-off-by: Runji Wang --- src/expr/core/src/codegen.rs | 3 ++- src/expr/macro/src/gen.rs | 19 ++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/expr/core/src/codegen.rs b/src/expr/core/src/codegen.rs index c9022e40aec91..e944f43950fdc 100644 --- a/src/expr/core/src/codegen.rs +++ b/src/expr/core/src/codegen.rs @@ -12,8 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//! This module contains imports that are used in the generated code for the `#[function]` macro. + pub use async_trait::async_trait; pub use futures_async_stream::try_stream; pub use futures_util::stream::BoxStream; -pub use itertools::multizip; pub use linkme; diff --git a/src/expr/macro/src/gen.rs b/src/expr/macro/src/gen.rs index 1185df8a194b0..7174b3adf29ed 100644 --- a/src/expr/macro/src/gen.rs +++ b/src/expr/macro/src/gen.rs @@ -484,10 +484,6 @@ impl FunctionAttr { } } else { // no optimization - let array_zip = match children_indices.len() { - 0 => quote! { std::iter::repeat(()).take(input.capacity()) }, - _ => quote! { multizip((#(#arrays.iter(),)*)) }, - }; let let_variadic = variadic.then(|| { quote! { let variadic_row = variadic_input.row_at_unchecked_vis(i); @@ -497,18 +493,18 @@ impl FunctionAttr { let mut builder = #builder_type::with_type(input.capacity(), self.context.return_type.clone()); if input.is_compacted() { - for (i, (#(#inputs,)*)) in #array_zip.enumerate() { + for i in 0..input.capacity() { + #(let #inputs = unsafe { #arrays.value_at_unchecked(i) };)* #let_variadic #append_output } } else { - // allow using `zip` for performance - #[allow(clippy::disallowed_methods)] - for (i, ((#(#inputs,)*), visible)) in #array_zip.zip(input.visibility().iter()).enumerate() { - if !visible { + for i in 0..input.capacity() { + if unsafe { !input.visibility().is_set_unchecked(i) } { builder.append_null(); continue; } + #(let #inputs = unsafe { #arrays.value_at_unchecked(i) };)* #let_variadic #append_output } @@ -1179,10 +1175,11 @@ impl FunctionAttr { let mut index_builder = I32ArrayBuilder::new(self.chunk_size); #(let mut #builders = #builder_types::with_type(self.chunk_size, #return_types);)* - for (i, ((#(#inputs,)*), visible)) in multizip((#(#arrays.iter(),)*)).zip_eq_fast(input.visibility().iter()).enumerate() { - if !visible { + for i in 0..input.capacity() { + if unsafe { !input.visibility().is_set_unchecked(i) } { continue; } + #(let #inputs = unsafe { #arrays.value_at_unchecked(i) };)* for output in #iter { index_builder.append(Some(i as i32)); match #output {