Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions datafusion/physical-plan/src/joins/nested_loop_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ pub struct NestedLoopJoinExec {
pub(crate) filter: Option<JoinFilter>,
/// How the join is performed
pub(crate) join_type: JoinType,
/// The schema once the join is applied
/// The full concatenated schema of left and right children should be distinct from
/// the output schema of the operator
join_schema: SchemaRef,
/// Future that consumes left input and buffers it in memory
///
Expand Down Expand Up @@ -564,7 +565,7 @@ impl ExecutionPlan for NestedLoopJoinExec {
self.right.partition_statistics(None)?,
vec![],
&self.join_type,
&self.join_schema,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to update the comment in self.join_schema to clarify that it's the concatenated schema of left and right child, without applying the projection

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

&self.schema(),
)
}

Expand Down Expand Up @@ -1557,6 +1558,26 @@ pub(crate) mod tests {
Ok(())
}

#[tokio::test]
async fn join_has_correct_stats() -> Result<()> {
let left = build_left_table();
let right = build_right_table();
let nested_loop_join = NestedLoopJoinExec::try_new(
left,
right,
None,
&JoinType::Left,
Some(vec![1, 2]),
)?;
let stats = nested_loop_join.partition_statistics(None)?;
assert_eq!(
nested_loop_join.schema().fields().len(),
stats.column_statistics.len(),
);
assert_eq!(2, stats.column_statistics.len());
Ok(())
}

#[rstest]
#[tokio::test]
async fn join_right_semi_with_filter(
Expand Down