Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xudong963 committed May 24, 2024
1 parent 56c99d0 commit d165350
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/query/sql/src/planner/optimizer/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ async fn optimize_merge_into(mut opt_ctx: OptimizerContext, plan: Box<MergeInto>
join_s_expr = merge_source_optimizer.optimize(&join_s_expr)?;
enable_right_broadcast = true;
}

let distributed = !join_s_expr.has_merge_exchange();
Ok(Plan::MergeInto(Box::new(MergeInto {
input: Box::new(join_s_expr),
distributed: true,
distributed,
change_join_order,
columns_set: new_columns_set.clone(),
enable_right_broadcast,
Expand Down
7 changes: 7 additions & 0 deletions src/query/sql/src/planner/optimizer/s_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ impl SExpr {
.collect::<Vec<_>>();
self.children = children;
}

pub fn has_merge_exchange(&self) -> bool {
if let RelOperator::Exchange(Exchange::Merge) = self.plan.as_ref() {
mreturn true;
}
self.children.iter().any(|child| child.has_merge_exchange())
}
}

fn find_subquery(rel_op: &RelOperator) -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,10 +847,10 @@ insert into t11 values (1, 10),(2, 20),(3, 30),(4, 40);
statement ok
insert into t12 values (1, 10),(2, 20),(3, 30),(4, 40);

#query T
#MERGE INTO t11 USING(SELECT NULL AS c0 FROM t12) AS t12 ON (t11.a OR TRUE) WHEN MATCHED AND TRUE THEN DELETE;
#----
#4
query T
MERGE INTO t11 USING(SELECT NULL AS c0 FROM t12) AS t12 ON (t11.a OR TRUE) WHEN MATCHED AND TRUE THEN DELETE;
----
4

query T
select count(*) from t11;
Expand Down

0 comments on commit d165350

Please sign in to comment.