Skip to content

Commit

Permalink
fix name with `
Browse files Browse the repository at this point in the history
  • Loading branch information
JackTan25 committed Oct 10, 2023
1 parent c135e78 commit 6726038
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/query/sql/src/planner/binder/merge_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl Binder {
let mut name_map = HashMap::<String, Vec<IndexType>>::new();
for column in source_output_columns {
name_map
.entry(column.column_name.clone())
.entry(column.column_name.trim_matches("`").to_string())
.or_insert_with(|| vec![])
.push(column.index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,13 @@ impl Processor for MatchedSplitProcessor {
.delete_mutator
.delete_by_expr(current_block)?;

// delete all
if !row_ids.is_empty() {
row_ids = row_ids.add_meta(Some(Box::new(RowIdKind::Delete)))?;
self.output_data_row_id_data.push(row_ids);
}

if stage_block.is_empty() {
// delete all
if !row_ids.is_empty() {
row_ids = row_ids.add_meta(Some(Box::new(RowIdKind::Delete)))?;
self.output_data_row_id_data.push(row_ids);
}
return Ok(());
}
current_block = stage_block;
Expand Down
30 changes: 30 additions & 0 deletions tests/sqllogictests/suites/base/09_fuse_engine/09_0026_merge_into
Original file line number Diff line number Diff line change
Expand Up @@ -507,5 +507,35 @@ select * from cluster_target;
3 a 3
12 b 1

## add more tests
statement ok
create table target_test(a int,b string);

statement ok
insert into target_test values(1,'a'),(2,'b'),(3,'c');

statement ok
create table source_test(a int,b string,is_databend_deleted bool);

statement ok
insert into source_test values(1,'d',true),(2,'e',true),(3,'f',false),(4,'e',true),(5,'f',false);

statement ok
create stage source_parquet file_format = (type = parquet);

statement ok
copy into @source_parquet from (select * from source_test);

statement ok
merge into `target_test` as tt using (select `a`,`b`,`is_databend_deleted` from @source_parquet (pattern => '.*[.]parquet')) as ss on (ss.`a` = tt.`a`)
when matched and ss.`is_databend_deleted` = true then delete when matched then update * when not matched and ss.`is_databend_deleted` = false then insert *;

query TT
select * from target_test order by a;
----
3 f
5 f

statement ok
set enable_experimental_merge_into = 0;

0 comments on commit 6726038

Please sign in to comment.