make sure no duplicate records exists during eval and merge (#5633)

This commit is contained in:
WindSoilder
2022-05-26 08:10:31 +08:00
committed by GitHub
parent 8e98df8b28
commit 9602e82029
3 changed files with 77 additions and 10 deletions

View File

@ -472,8 +472,18 @@ pub fn eval_expression(
let mut cols = vec![];
let mut vals = vec![];
for (col, val) in fields {
cols.push(eval_expression(engine_state, stack, col)?.as_string()?);
vals.push(eval_expression(engine_state, stack, val)?);
// avoid duplicate cols.
let col_name = eval_expression(engine_state, stack, col)?.as_string()?;
let pos = cols.iter().position(|c| c == &col_name);
match pos {
Some(index) => {
vals[index] = eval_expression(engine_state, stack, val)?;
}
None => {
cols.push(col_name);
vals.push(eval_expression(engine_state, stack, val)?);
}
}
}
Ok(Value::Record {