ygf11 commented on code in PR #5156: URL: https://github.com/apache/arrow-datafusion/pull/5156#discussion_r1094206703
########## datafusion/core/src/physical_plan/joins/nested_loop_join.rs: ########## @@ -479,6 +404,185 @@ impl NestedLoopJoinStream { } }) } + + fn poll_next_impl_for_build_right( + &mut self, + cx: &mut std::task::Context<'_>, + ) -> Poll<Option<Result<RecordBatch>>> { + // all right row + let right_data = match ready!(self.inner_table.get(cx)) { + Ok(data) => data, + Err(e) => return Poll::Ready(Some(Err(e))), + }; + + // for build right, bitmap is not needed. + let mut empty_visited_left_side = BooleanBufferBuilder::new(0); + self.outer_table + .poll_next_unpin(cx) + .map(|maybe_batch| match maybe_batch { + Some(Ok(left_batch)) => { + let result = join_left_and_right_batch( + &left_batch, + right_data, + self.join_type, + self.filter.as_ref(), + &self.column_indices, + &self.schema, + &mut empty_visited_left_side, + ); + Some(result) + } + Some(err) => Some(err), + None => None, + }) + } +} + +fn join_left_and_right_batch( + left_batch: &RecordBatch, + right_batch: &RecordBatch, + join_type: JoinType, + filter: Option<&JoinFilter>, + column_indices: &[ColumnIndex], + schema: &Schema, + visited_left_side: &mut BooleanBufferBuilder, +) -> Result<RecordBatch> { + let indices_result = (0..left_batch.num_rows()) + .map(|left_row_index| { + build_join_indices(left_row_index, right_batch, left_batch, filter) + }) + .collect::<Result<Vec<(UInt64Array, UInt32Array)>>>(); Review Comment: The type of join_indices is always (UInt64Array, UInt32Array) now no matter which side is single partition. We can do better here: * Always use `UInt64Array` for the single partition side, and the other side is `UInt32Array`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org