yjshen commented on a change in pull request #2001:
URL: https://github.com/apache/arrow-datafusion/pull/2001#discussion_r825553116



##########
File path: datafusion-proto/src/from_proto.rs
##########
@@ -155,9 +156,12 @@ impl TryFrom<&protobuf::DfSchema> for DFSchema {
             .iter()
             .map(|c| c.try_into())
             .collect::<Result<Vec<DFField>, _>>()?;
-        // https://github.com/apache/arrow-datafusion/issues/1977
-        #[allow(deprecated)]
-        Ok(DFSchema::new(fields)?)
+        let metadata = df_schema
+            .metadata
+            .iter()
+            .map(|m| (m.0.clone(), m.1.clone()))
+            .collect::<HashMap<String, String>>();
+        Ok(DFSchema::new_with_metadata(fields, metadata)?)

Review comment:
       ```suggestion
           Ok(DFSchema::new_with_metadata(fields, df_schema.metadata.clone())?)
   ```

##########
File path: datafusion-proto/src/to_proto.rs
##########
@@ -290,7 +291,12 @@ impl From<&DFField> for protobuf::DfField {
 impl From<&DFSchemaRef> for protobuf::DfSchema {
     fn from(s: &DFSchemaRef) -> protobuf::DfSchema {
         let columns = s.fields().iter().map(|f| f.into()).collect::<Vec<_>>();
-        protobuf::DfSchema { columns }
+        let metadata = s
+            .metadata()
+            .iter()
+            .map(|m| (m.0.clone(), m.1.clone()))
+            .collect::<HashMap<_, _>>();
+        protobuf::DfSchema { columns, metadata }

Review comment:
       ```suggestion
           protobuf::DfSchema { columns , metadata: s.metadata().clone() }
   ```




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