Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix master #2692

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions arrow/src/compute/kernels/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ pub fn concat(arrays: &[&dyn Array]) -> Result<ArrayRef> {
}

/// Concatenates `batches` together into a single record batch.
pub fn concat_batches(schema: &SchemaRef, batches: &[RecordBatch]) -> Result<RecordBatch> {
pub fn concat_batches(
schema: &SchemaRef,
batches: &[RecordBatch],
) -> Result<RecordBatch> {
if batches.is_empty() {
return Ok(RecordBatch::new_empty(schema.clone()));
}
Expand Down Expand Up @@ -613,16 +616,16 @@ mod tests {
Arc::new(StringArray::from(vec!["a", "b"])),
],
)
.unwrap();
.unwrap();
let batch2 = RecordBatch::try_new(
schema.clone(),
vec![
Arc::new(Int32Array::from(vec![3, 4])),
Arc::new(StringArray::from(vec!["c", "d"])),
],
)
.unwrap();
let new_batch = RecordBatch::concat(&schema, &[batch1, batch2]).unwrap();
.unwrap();
let new_batch = concat_batches(&schema, &[batch1, batch2]).unwrap();
assert_eq!(new_batch.schema().as_ref(), schema.as_ref());
assert_eq!(2, new_batch.num_columns());
assert_eq!(4, new_batch.num_rows());
Expand All @@ -634,7 +637,7 @@ mod tests {
Field::new("a", DataType::Int32, false),
Field::new("b", DataType::Utf8, false),
]));
let batch = RecordBatch::concat(&schema, &[]).unwrap();
let batch = concat_batches(&schema, &[]).unwrap();
assert_eq!(batch.schema().as_ref(), schema.as_ref());
assert_eq!(0, batch.num_rows());
}
Expand All @@ -656,16 +659,16 @@ mod tests {
Arc::new(StringArray::from(vec!["a", "b"])),
],
)
.unwrap();
.unwrap();
let batch2 = RecordBatch::try_new(
schema2,
vec![
Arc::new(Int32Array::from(vec![3, 4])),
Arc::new(StringArray::from(vec!["c", "d"])),
],
)
.unwrap();
let error = RecordBatch::concat(&schema1, &[batch1, batch2]).unwrap_err();
.unwrap();
let error = concat_batches(&schema1, &[batch1, batch2]).unwrap_err();
assert_eq!(
error.to_string(),
"Invalid argument error: batches[1] schema is different with argument schema.",
Expand Down