Create a new schema that contains the fields from this schema followed by the fields from the supplied schema. An error will be returned if there are duplicate field names.
(&self, schema: &DFSchema)
| 285 | /// Create a new schema that contains the fields from this schema followed by the fields |
| 286 | /// from the supplied schema. An error will be returned if there are duplicate field names. |
| 287 | pub fn join(&self, schema: &DFSchema) -> Result<Self> { |
| 288 | let mut schema_builder = SchemaBuilder::new(); |
| 289 | schema_builder.extend(self.inner.fields().iter().cloned()); |
| 290 | schema_builder.extend(schema.fields().iter().cloned()); |
| 291 | let new_schema = schema_builder.finish(); |
| 292 | |
| 293 | let mut new_metadata = self.inner.metadata.clone(); |
| 294 | new_metadata.extend(schema.inner.metadata.clone()); |
| 295 | let new_schema_with_metadata = new_schema.with_metadata(new_metadata); |
| 296 | |
| 297 | let mut new_qualifiers = self.field_qualifiers.clone(); |
| 298 | new_qualifiers.extend_from_slice(schema.field_qualifiers.as_slice()); |
| 299 | |
| 300 | let new_self = Self { |
| 301 | inner: Arc::new(new_schema_with_metadata), |
| 302 | field_qualifiers: new_qualifiers, |
| 303 | functional_dependencies: FunctionalDependencies::empty(), |
| 304 | }; |
| 305 | new_self.check_names()?; |
| 306 | Ok(new_self) |
| 307 | } |
| 308 | |
| 309 | /// Modify this schema by appending the fields from the supplied schema, ignoring any |
| 310 | /// duplicate fields. |