jonathanc-n commented on code in PR #16443: URL: https://github.com/apache/datafusion/pull/16443#discussion_r2181119355
########## datafusion/physical-plan/src/joins/nested_loop_join.rs: ########## @@ -828,13 +833,127 @@ impl<T: BatchTransformer> NestedLoopJoinStream<T> { handle_state!(self.process_probe_batch()) } NestedLoopJoinStreamState::ExhaustedProbeSide => { - handle_state!(self.process_unmatched_build_batch()) + handle_state!(self.prepare_unmatched_output_indices()) + } + NestedLoopJoinStreamState::OutputUnmatchedBuildRows(_) => { + handle_state!(self.build_unmatched_output()) } NestedLoopJoinStreamState::Completed => Poll::Ready(None), }; } } + fn get_next_join_result(&mut self) -> Result<Option<RecordBatch>> { + let (left_indices, right_indices, start) = + self.join_result_status.as_mut().ok_or_else(|| { + datafusion_common::_internal_datafusion_err!( + "should have join_result_status" + ) + })?; + + let left_batch = self + .left_data + .as_ref() + .ok_or_else(|| { + datafusion_common::_internal_datafusion_err!("should have left_batch") + })? + .batch(); + + let right_batch = match &self.state { + NestedLoopJoinStreamState::ProcessProbeBatch(record_batch) => record_batch, + NestedLoopJoinStreamState::OutputUnmatchedBuildRows(record_batch) => { + record_batch + } + _ => { + return internal_err!( + "state should be ProcessProbeBatch or OutputUnmatchBatch" + ) + } + }; + + let current_start = *start; + + if left_indices.is_empty() && right_indices.is_empty() && current_start == 0 { Review Comment: Can we build and return an empty batch instead of calling build_batch_from_indices? -- 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...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org