Skip to content

Should be able to specify a name when deriving ArrowField #1774

@teh-cmc

Description

@teh-cmc

You should be able to do this:

#[derive(ArrowField)]
#[arrow_field(name = "rerun.tuid")]
pub struct Tuid {
    /// Approximate nanoseconds since epoch.
    time_ns: u64,

    /// Initialized to something random on each thread,
    /// then incremented for each new [`Tuid`] being allocated.
    inc: u64,
}

in order to yield this:

impl arrow2_convert::field::ArrowField for Tuid {
    type Type = Self;

    fn data_type() -> arrow2::datatypes::DataType {
        let datatype = arrow2::datatypes::DataType::Struct(<[_]>::into_vec(Box::new([
            <u64 as arrow2_convert::field::ArrowField>::field("time_ns"),
            <u64 as arrow2_convert::field::ArrowField>::field("inc"),
        ])));
        DataType::Extension("rerun.tuid".into(), Box::new(datatype), None)
    }
}

Similarly, the Component trait should always generate extension types, automatically injecting the component name into the ArrowField definition (related to #1696).

This is not just about dev experience, this opens many doors in terms of data inspection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions