Skip to content

Commit 0a218c8

Browse files
authored
fix: the result of the first parameter of eval_or_filters will affect the subsequent parameters (#18782)
1 parent b856a63 commit 0a218c8

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed

src/query/expression/src/evaluator.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,11 +1420,12 @@ impl<'a> Evaluator<'a> {
14201420
fn eval_or_filters(
14211421
&self,
14221422
args: &[Expr],
1423-
mut validity: Option<Bitmap>,
1423+
validity: Option<Bitmap>,
14241424
options: &mut EvaluateOptions,
14251425
) -> Result<Value<AnyType>> {
14261426
assert!(args.len() >= 2);
14271427

1428+
let mut result = validity.clone();
14281429
for arg in args {
14291430
let cond = self.partial_run(arg, validity.clone(), options)?;
14301431
match &cond {
@@ -1443,20 +1444,20 @@ impl<'a> Evaluator<'a> {
14431444
Column::Boolean(boolean_column) => boolean_column.clone(),
14441445
_ => unreachable!(),
14451446
};
1446-
match &validity {
1447+
match &result {
14471448
Some(v) => {
1448-
validity = Some(v | (&flag));
1449+
result = Some(v | (&flag));
14491450
}
14501451
None => {
1451-
validity = Some(flag);
1452+
result = Some(flag);
14521453
}
14531454
}
14541455
}
14551456
_ => unreachable!(),
14561457
}
14571458
}
14581459

1459-
match validity {
1460+
match result {
14601461
Some(bitmap) => Ok(Value::Column(Column::Boolean(bitmap))),
14611462
None => Ok(Value::Scalar(Scalar::Boolean(false))),
14621463
}

tests/sqllogictests/suites/base/03_common/03_0025_delete_from.test

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,5 +355,46 @@ select count(*) from t;
355355
statement ok
356356
drop table t all
357357

358+
statement ok
359+
CREATE OR REPLACE TABLE test_delete_or_filters (group_flag VARCHAR NULL, af_cohort_install DOUBLE NULL) ENGINE=FUSE;
360+
361+
statement ok
362+
INSERT INTO test_delete_or_filters
363+
VALUES ('af_cohort_retained', 50594),
364+
('af_cohort_retained', 49465),
365+
('af_cohort_retained', 49176),
366+
('af_cohort_retained', 48575),
367+
('af_cohort_retained', 53555),
368+
('af_cohort_retained', 54150),
369+
('af_cohort_receipt', 50594),
370+
('af_cohort_receipt', 49465),
371+
('af_cohort_receipt', 49176),
372+
('af_cohort_receipt', 48575),
373+
('af_cohort_receipt', 53555),
374+
('af_cohort_receipt', 54150),
375+
('af_cohort_deposit', 25000),
376+
('af_cohort_deposit', 24500),
377+
('af_cohort_deposit', 24000),
378+
('af_cohort_deposit', 23500),
379+
('af_cohort_deposit', 26000),
380+
('af_cohort_deposit', 27000),
381+
('af_cohort_deposit', 25500),
382+
('af_cohort_deposit', 26500),
383+
('normal_data', 10000),
384+
('normal_data', 11000),
385+
('normal_data', 12000),
386+
('normal_data', 13000);
387+
388+
statement ok
389+
delete from test_delete_or_filters where group_flag in ('af_cohort_deposit', 'af_cohort_receipt', 'af_cohort_retained');
390+
391+
query TI
392+
select * from test_delete_or_filters;
393+
----
394+
normal_data 10000.0
395+
normal_data 11000.0
396+
normal_data 12000.0
397+
normal_data 13000.0
398+
358399
statement ok
359400
DROP DATABASE db1

0 commit comments

Comments
 (0)