pub struct Field {
pub name: String,
pub dtype: ArrowType,
pub nullable: bool,
pub metadata: BTreeMap<String, String>,
}Expand description
§Field
§Description
Field struct supporting:
- Array metadata such as type, name, nullability, etc.
- Light metadata, e.g. a few key-value pairs.
- Later
Schemaconstruction during Arrow FFI.
§Tips:
-
Fieldis cloned often, so it is best kept any metadata lightweight to avoid performance penalties.SuperTablewraps it in Arc. -
For
Datetimearrays,Fieldcarries the logicalArrowtype. The physical type remains a single integer-backedDatetime, while the logical type specifies its intended semantics. i.e.:Date32Date64Time32(TimeUnit)Time64(TimeUnit)Duration32(TimeUnit)Duration64(TimeUnit)Timestamp(TimeUnit)Interval(IntervalUnit) -
This ensures that when sent over Arrow C-FFI (or
to_apache_arrow()), it converts to the correct external type. Whilst, avoiding proliferating many specialised types prematurely, keeping the API and binary size minimal.
Fields§
§name: String§dtype: ArrowType§nullable: bool§metadata: BTreeMap<String, String>Implementations§
Source§impl Field
impl Field
Sourcepub fn new<T>(
name: T,
dtype: ArrowType,
nullable: bool,
metadata: Option<BTreeMap<String, String>>,
) -> Field
pub fn new<T>( name: T, dtype: ArrowType, nullable: bool, metadata: Option<BTreeMap<String, String>>, ) -> Field
Constructs a new Field. If the provided name is empty or only whitespace,
a globally unique name like UnnamedField1 will generate.
Sourcepub fn from_array(
name: impl Into<String>,
array: &Array,
metadata: Option<BTreeMap<String, String>>,
) -> Field
pub fn from_array( name: impl Into<String>, array: &Array, metadata: Option<BTreeMap<String, String>>, ) -> Field
Constructs a new Field from an Array enum instance.
Derives the dtype and nullability directly from the inner array.
For Duration, Time, Timestamp and Interval types, use Field::new().