You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/07/11 04:59:11 UTC

[GitHub] [arrow-rs] silathdiir commented on a change in pull request #537: Implement `RecordBatch::concat`

silathdiir commented on a change in pull request #537:
URL: https://github.com/apache/arrow-rs/pull/537#discussion_r667422194



##########
File path: arrow/src/record_batch.rs
##########
@@ -353,6 +354,35 @@ impl RecordBatch {
         let schema = Arc::new(Schema::new(fields));
         RecordBatch::try_new(schema, columns)
     }
+
+    /// Concatenates `batches` together into a single record batch.
+    pub fn concat(schema: &SchemaRef, batches: &[Self]) -> Result<Self> {
+        if batches.is_empty() {
+            return Ok(RecordBatch::new_empty(schema.clone()));
+        }
+        let field_num = schema.fields().len();
+        if let Some((i, _)) = batches
+            .iter()
+            .enumerate()
+            .find(|&(_, batch)| batch.num_columns() < field_num)

Review comment:
       I could not confirm if a batch of more columns than schema could be allowed to be concatenated, as below test case [concat_record_batches_of_similar_schemas](https://github.com/apache/arrow-rs/pull/537/files#diff-9841f61221a67c626eb60a49f2aeb7de6c1a16ab478bc7cb2675f5807b32b8e6R700).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org