-
Couldn't load subscription status.
- Fork 3.9k
Closed
Description
arrow/rust/arrow/src/datatypes.rs
Lines 1832 to 1860 in ab5fc97
| /// Merge schema into self if it is compatible. Struct fields will be merged recursively. | |
| /// | |
| /// Example: | |
| /// | |
| /// ``` | |
| /// use arrow::datatypes::*; | |
| /// | |
| /// let merged = Schema::try_merge(&vec![ | |
| /// Schema::new(vec![ | |
| /// Field::new("c1", DataType::Int64, false), | |
| /// Field::new("c2", DataType::Utf8, false), | |
| /// ]), | |
| /// Schema::new(vec![ | |
| /// Field::new("c1", DataType::Int64, true), | |
| /// Field::new("c2", DataType::Utf8, false), | |
| /// Field::new("c3", DataType::Utf8, false), | |
| /// ]), | |
| /// ]).unwrap(); | |
| /// | |
| /// assert_eq!( | |
| /// merged, | |
| /// Schema::new(vec![ | |
| /// Field::new("c1", DataType::Int64, true), | |
| /// Field::new("c2", DataType::Utf8, false), | |
| /// Field::new("c3", DataType::Utf8, false), | |
| /// ]), | |
| /// ); | |
| /// ``` | |
| pub fn try_merge(schemas: &[Self]) -> Result<Self> { |
I was looking at this code yesterday while using it in IOx – https://github.com/influxdata/influxdb_iox/pull/703
Even though Schema::try_merge requires a slice of Schemas (not schema refs), it copies all of its fields. This is not ideal in the common case where most of the fields in the Schema will be the same
Reporter: Andrew Lamb / @alamb
Assignee: Andrew Lamb / @alamb
PRs and other links:
Note: This issue was originally created as ARROW-11414. Please see the migration documentation for further details.