niyue commented on code in PR #12812:
URL: https://github.com/apache/arrow/pull/12812#discussion_r844529994


##########
cpp/src/arrow/ipc/reader.cc:
##########
@@ -676,7 +676,14 @@ Result<std::shared_ptr<RecordBatch>> 
ReadRecordBatchInternal(
   }
   context.compression = compression;
   context.metadata_version = internal::GetMetadataVersion(message->version());
-  return LoadRecordBatch(batch, schema, inclusion_mask, context, file);
+
+  auto schema_with_custom_meta = schema;
+  if (message->custom_metadata() != nullptr) {
+    std::shared_ptr<KeyValueMetadata> md;
+    RETURN_NOT_OK(internal::GetKeyValueMetadata(message->custom_metadata(), 
&md));
+    schema_with_custom_meta = schema->WithMetadata(std::move(md));
+  }
+  return LoadRecordBatch(batch, schema_with_custom_meta, inclusion_mask, 
context, file);

Review Comment:
   When reading a batch, if the batch message contains some custom metadata, it 
will be used to create a new schema with the custom metadata when creating the 
record batch. If the batch message doesn't contain custom metadata, we still 
use the original schema for creating the record batch as usual.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to