Intersects multiple metadata instances for UNION operations. This function implements the intersection strategy used by UNION operations, where only metadata keys that exist in ALL inputs with identical values are preserved in the result. # Union Metadata Behavior Union operations require consistent metadata across all branches: - Only metadata keys present in ALL union branches are kept - For
(
metadatas: impl IntoIterator<Item = &'a SchemaFieldMetadata>,
)
| 646 | /// |
| 647 | /// A new `SchemaFieldMetadata` containing only the intersected metadata |
| 648 | pub fn intersect_metadata_for_union<'a>( |
| 649 | metadatas: impl IntoIterator<Item = &'a SchemaFieldMetadata>, |
| 650 | ) -> SchemaFieldMetadata { |
| 651 | let mut intersected: Option<SchemaFieldMetadata> = None; |
| 652 | |
| 653 | for metadata in metadatas { |
| 654 | // Skip empty metadata (e.g. from NULL literals or computed expressions) |
| 655 | // to avoid dropping metadata from branches that have it. |
| 656 | if metadata.is_empty() { |
| 657 | continue; |
| 658 | } |
| 659 | match &mut intersected { |
| 660 | None => { |
| 661 | intersected = Some(metadata.clone()); |
| 662 | } |
| 663 | Some(current) => { |
| 664 | // Only keep keys that exist in both with the same value |
| 665 | current.retain(|k, v| metadata.get(k) == Some(v)); |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | intersected.unwrap_or_default() |
| 671 | } |
| 672 | |
| 673 | /// UNNEST expression. |
| 674 | #[derive(Clone, PartialEq, Eq, PartialOrd, Hash, Debug)] |
searching dependent graphs…