Concatenates a `RelationDesc` onto the end of this `RelationDesc`. # Panics Panics if either `self` or `other` have columns that were added at a [`RelationVersion`] other than [`RelationVersion::root`] or if any columns were dropped. TODO(parkmycar): Move this method to [`RelationDescBuilder`].
(mut self, other: Self)
| 1150 | /// |
| 1151 | /// TODO(parkmycar): Move this method to [`RelationDescBuilder`]. |
| 1152 | pub fn concat(mut self, other: Self) -> Self { |
| 1153 | let self_len = self.typ.column_types.len(); |
| 1154 | |
| 1155 | for (typ, (_col_idx, meta)) in other.typ.column_types.into_iter().zip_eq(other.metadata) { |
| 1156 | assert_eq!(meta.added, RelationVersion::root()); |
| 1157 | assert_none!(meta.dropped); |
| 1158 | |
| 1159 | let new_idx = self.typ.columns().len(); |
| 1160 | let new_meta = ColumnMetadata { |
| 1161 | name: meta.name, |
| 1162 | typ_idx: new_idx, |
| 1163 | added: RelationVersion::root(), |
| 1164 | dropped: None, |
| 1165 | }; |
| 1166 | |
| 1167 | self.typ.column_types.push(typ); |
| 1168 | let prev = self.metadata.insert(ColumnIndex(new_idx), new_meta); |
| 1169 | |
| 1170 | assert_eq!(self.metadata.len(), self.typ.columns().len()); |
| 1171 | assert_none!(prev); |
| 1172 | } |
| 1173 | |
| 1174 | for k in other.typ.keys { |
| 1175 | let k = k.into_iter().map(|idx| idx + self_len).collect(); |
| 1176 | self = self.with_key(k); |
| 1177 | } |
| 1178 | self |
| 1179 | } |
| 1180 | |
| 1181 | /// Adds a new key for the relation. |
| 1182 | pub fn with_key(mut self, indices: Vec<usize>) -> Self { |