diff --git a/src/sql/execution/execute.rs b/src/sql/execution/execute.rs index 668fb9139..d1a428e27 100644 --- a/src/sql/execution/execute.rs +++ b/src/sql/execution/execute.rs @@ -69,15 +69,7 @@ pub fn execute(node: Node, txn: &impl Transaction) -> Result { Ok(transform::filter(source, predicate)) } - Node::HashJoin { - left, - left_field, - left_label: _, - right, - right_field, - right_label: _, - outer, - } => { + Node::HashJoin { left, left_field, right, right_field, outer } => { let right_size = right.size(); let left = execute(*left, txn)?; let right = execute(*right, txn)?; diff --git a/src/sql/planner/optimizer.rs b/src/sql/planner/optimizer.rs index 390390766..6fe3c3040 100644 --- a/src/sql/planner/optimizer.rs +++ b/src/sql/planner/optimizer.rs @@ -260,28 +260,16 @@ pub(super) fn join_type(node: Node) -> Result { predicate: Some(Expression::Equal(lhs, rhs)), outer, } => match (*lhs, *rhs) { - ( - Expression::Field(mut left_field, mut left_label), - Expression::Field(mut right_field, mut right_label), - ) => { + (Expression::Field(mut left_field, _), Expression::Field(mut right_field, _)) => { // The LHS field may be a field in the right table; swap them. if right_field < left_field { (left_field, right_field) = (right_field, left_field); - (left_label, right_label) = (right_label, left_label); } // The NestedLoopJoin predicate uses field indexes in the joined // row, while the HashJoin uses field indexes for each table // individually. Adjust the RHS field reference. right_field -= left.size(); - Node::HashJoin { - left, - left_field, - left_label, - right, - right_field, - right_label, - outer, - } + Node::HashJoin { left, left_field, right, right_field, outer } } (lhs, rhs) => { let predicate = Some(Expression::Equal(lhs.into(), rhs.into())); diff --git a/src/sql/planner/plan.rs b/src/sql/planner/plan.rs index 4780c435d..2432583ce 100644 --- a/src/sql/planner/plan.rs +++ b/src/sql/planner/plan.rs @@ -92,10 +92,8 @@ pub enum Node { HashJoin { left: Box, left_field: usize, - left_label: Label, right: Box, right_field: usize, - right_label: Label, outer: bool, }, /// Looks up the given values in a secondary index and emits matching rows. @@ -153,21 +151,11 @@ impl Node { Self::Filter { source, predicate } => { Self::Filter { source: transform(source)?, predicate } } - Self::HashJoin { - left, - left_field, - left_label, - right, - right_field, - right_label, - outer, - } => Self::HashJoin { + Self::HashJoin { left, left_field, right, right_field, outer } => Self::HashJoin { left: transform(left)?, left_field, - left_label, right: transform(right)?, right_field, - right_label, outer, }, Self::Limit { source, limit } => Self::Limit { source: transform(source)?, limit }, @@ -441,22 +429,13 @@ impl Node { write!(f, "Filter: {predicate}")?; source.format(f, prefix, false, true)?; } - Self::HashJoin { - left, - left_field, - left_label, - right, - right_field, - right_label, - outer, - .. - } => { + Self::HashJoin { left, left_field, right, right_field, outer } => { let kind = if *outer { "outer" } else { "inner" }; - let left_label = match left_label { + let left_label = match left.column_label(*left_field) { Label::None => format!("left #{left_field}"), label => format!("{label}"), }; - let right_label = match right_label { + let right_label = match right.column_label(*right_field) { Label::None => format!("right #{right_field}"), label => format!("{label}"), };