alamb commented on code in PR #2024:
URL: https://github.com/apache/arrow-rs/pull/2024#discussion_r916299663
##########
arrow/src/datatypes/field.rs:
##########
@@ -144,19 +145,62 @@ impl Field {
&self.name
}
- /// Returns an immutable reference to the `Field`'s data-type.
+ /// Set the name of the [`Field`].
+ ///
+ /// ```
+ /// # use arrow::datatypes::*;
+ /// let field = Field::new("c1", DataType::Int64, false)
+ /// .with_name("c2");
+ ///
+ /// assert_eq!(field.name(), "c2");
+ /// ```
+ pub fn with_name(mut self, name: impl Into<String>) -> Self {
+ self.name = name.into();
+ self
+ }
+
+ /// Returns an immutable reference to the [`Field`]'s [`DataType`].
#[inline]
pub const fn data_type(&self) -> &DataType {
&self.data_type
}
- /// Indicates whether this `Field` supports null values.
+ /// Set [`DataType`] of the [`Field`]
+ ///
+ /// ```
+ /// # use arrow::datatypes::*;
+ /// let field = Field::new("c1", DataType::Int64, false)
+ /// .with_data_type(DataType::Utf8);
+ ///
+ /// assert_eq!(field.data_type(), &DataType::Utf8);
+ /// ```
+ pub fn with_data_type(mut self, data_type: DataType) -> Self {
+ self.data_type = data_type;
+ self
+ }
+
+ /// Indicates whether this [`Field`] supports null values.
#[inline]
pub const fn is_nullable(&self) -> bool {
self.nullable
}
- /// Returns a (flattened) vector containing all fields contained within
this field (including it self)
+ /// Set `nullable` of the [`Field`]
Review Comment:
```suggestion
/// Set `nullable` of the [`Field`] and returns self.
```
--
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]