apache / arrow-rs

Official Rust implementation of Apache Arrow
https://arrow.apache.org/
Apache License 2.0
2.62k stars 802 forks source link

Ability to create Schema with new fields but same everytthing else #6575

Open alamb opened 1 month ago

alamb commented 1 month ago

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

It is common downstream to manipulate Schamas in someway, such as to reorder the fields or select a subset of the fields Schema also contains metadata, and thus care must be taken when creating derivative schemas to call Schema::new_with_metadata Forgetting to do this has lead to several issues downstream in DataFusion -- see list on https://github.com/apache/datafusion/issues/12733

Describe the solution you'd like I would like it to be easier to create a Schema with different fields and different properties

Describe alternatives you've considered

Additional context

alamb commented 1 month ago

Actually, reading the code i see SchemaBuilder already mostly does this, though it looks like it is not super clear how to specify a field subset. I will play around with some examples