jiacai2050 commented on a change in pull request #1914:
URL: https://github.com/apache/arrow-datafusion/pull/1914#discussion_r820246063
##########
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:
Builder-style API is good itself, but is not suitable here I think.
As you can see, schema conversion between Array and datafusion is used in
many places, the compiler will output an warning when `new` is marked as
deprecated, but when adopt builder-style API, no warning will be made, and it
would be very easy to lost metadata when doing nested conversion.
--
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]