Skip to content

Commit

Permalink
Fix edge case when merging subresults
Browse files Browse the repository at this point in the history
  • Loading branch information
cswinter committed Mar 29, 2024
1 parent 06d948a commit b6aef44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/engine/data_types/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,7 @@ impl<'a, T: VecData<T> + 'a> Data<'a> for &'a [T] {

fn append_all(&mut self, other: &dyn Data<'a>, count: usize) -> Option<BoxedData<'a>> {
let mut owned = Vec::from(*self);
owned.append_all(other, count);
Some(Box::new(owned))
owned.append_all(other, count).or(Some(Box::new(owned)))
}

fn type_error(&self, func_name: &str) -> String {
Expand Down
14 changes: 7 additions & 7 deletions src/engine/execution/batch_merging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,24 +297,24 @@ pub fn combine<'a>(
let mut result = Vec::with_capacity(batch1.columns.len());
let show = batch1.show || batch2.show;
for (mut col1, col2) in batch1.columns.into_iter().zip(batch2.columns) {
if show {
println!("Merging columns");
println!("{}", col1.display());
println!("{}", col2.display());
}
let count = if col1.len() >= limit {
0
} else {
min(col2.len(), limit - col1.len())
};
if show {
println!("Merging columns (count={count})");
println!("col1={}", col1.display());
println!("col2={}", col2.display());
}
if let Some(newcol) = col1.append_all(&*col2, count) {
if show {
println!("{}", newcol.display());
println!("newcol={}", newcol.display());
}
result.push(newcol)
} else {
if show {
println!("{}", col1.display());
println!("newcol=col1={}", col1.display());
}
result.push(col1)
}
Expand Down

0 comments on commit b6aef44

Please sign in to comment.