jiacai2050 commented on a change in pull request #1914:
URL: https://github.com/apache/arrow-datafusion/pull/1914#discussion_r820655067



##########
File path: datafusion-common/src/dfschema.rs
##########
@@ -36,16 +36,30 @@ pub type DFSchemaRef = Arc<DFSchema>;
 pub struct DFSchema {
     /// Fields
     fields: Vec<DFField>,
+    /// Additional metadata in form of key value pairs
+    metadata: HashMap<String, String>,
 }
 
 impl DFSchema {
     /// Creates an empty `DFSchema`
     pub fn empty() -> Self {
-        Self { fields: vec![] }
+        Self {
+            fields: vec![],
+            metadata: HashMap::new(),
+        }
     }
 
+    #[deprecated(since = "7.0.0", note = "please use `new_with_metadata` 
instead")]
     /// Create a new `DFSchema`
     pub fn new(fields: Vec<DFField>) -> Result<Self> {
+        Self::new_with_metadata(fields, HashMap::new())
+    }
+
+    /// Create a new `DFSchema`
+    pub fn new_with_metadata(

Review comment:
       As you can see in 
https://github.com/apache/arrow-datafusion/pull/1914/files#diff-c1ef69547042f0c07aa616c9d5d58cbe2a3c5720f7237c948c99012d6cc0024a
   
   Those optimizers will rewrite plan, if any optimizer forget to attach 
metadata to newly-created plan, then metadata is lost, it's very easy to miss 
that without compiler's help.
   




-- 
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-unsubscr...@arrow.apache.org

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


Reply via email to