Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid materializing local varaibles when creating sortMergeJoinExec #4566

Merged
merged 2 commits into from
Dec 10, 2022
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
36 changes: 12 additions & 24 deletions datafusion/core/src/physical_plan/joins/sort_merge_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,33 +113,21 @@ impl SortMergeJoinExec {
)));
}

let (left_expr, right_expr): (Vec<_>, Vec<_>) = on
let (left_sort_exprs, right_sort_exprs): (Vec<_>, Vec<_>) = on
.iter()
.map(|(l, r)| {
(
Arc::new(l.clone()) as Arc<dyn PhysicalExpr>,
Arc::new(r.clone()) as Arc<dyn PhysicalExpr>,
)
})
.unzip();

let left_sort_exprs = left_expr
.into_iter()
.zip(sort_options.iter())
.map(|(k, sort_op)| PhysicalSortExpr {
expr: k,
options: *sort_op,
})
.collect::<Vec<_>>();

let right_sort_exprs = right_expr
.into_iter()
.zip(sort_options.iter())
.map(|(k, sort_op)| PhysicalSortExpr {
expr: k,
options: *sort_op,
.map(|((l, r), sort_op)| {
let left = PhysicalSortExpr {
expr: Arc::new(l.clone()) as Arc<dyn PhysicalExpr>,
options: *sort_op,
};
let right = PhysicalSortExpr {
expr: Arc::new(r.clone()) as Arc<dyn PhysicalExpr>,
options: *sort_op,
};
(left, right)
})
.collect::<Vec<_>>();
.unzip();

let output_ordering = match join_type {
JoinType::Inner
Expand Down