You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "viirya (via GitHub)" <gi...@apache.org> on 2023/04/06 19:05:35 UTC

[GitHub] [arrow-rs] viirya commented on a diff in pull request #4028: Add RecordBatch::with_schema

viirya commented on code in PR #4028:
URL: https://github.com/apache/arrow-rs/pull/4028#discussion_r1160157083


##########
arrow-array/src/record_batch.rs:
##########
@@ -204,6 +204,25 @@ impl RecordBatch {
         })
     }
 
+    /// Override the schema of this [`RecordBatch`]
+    ///
+    /// Returns an error if `schema` is not a superset of the current schema
+    /// as determined by [`Schema::contains`]
+    pub fn with_schema(self, schema: SchemaRef) -> Result<Self, ArrowError> {
+        if !schema.contains(self.schema.as_ref()) {
+            return Err(ArrowError::SchemaError(format!(
+                "{schema} is not a superset of {}",
+                self.schema
+            )));
+        }

Review Comment:
   It looks like this is particular used for metadata only? Although looks like you can override the schema with new field (superset?), but this batch doesn't have it.



-- 
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