Skip to content

Commit

Permalink
fix table function with no argument
Browse files Browse the repository at this point in the history
Signed-off-by: Runji Wang <[email protected]>
  • Loading branch information
wangrunji0408 committed May 30, 2024
1 parent 0c8b036 commit c31d1d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/expr/core/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
19 changes: 8 additions & 11 deletions src/expr/macro/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c31d1d8

Please sign in to comment.