Add a new column to the schema, backfilling existing rows with nulls/defaults.
(&mut self, name: String, column_type: ColumnType, nullable: bool)
| 199 | |
| 200 | /// Add a new column to the schema, backfilling existing rows with nulls/defaults. |
| 201 | pub fn add_column(&mut self, name: String, column_type: ColumnType, nullable: bool) { |
| 202 | if self.schema.columns.iter().any(|c| c.name == name) { |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | let existing_rows = self.row_count; |
| 207 | let mut col = ColumnData::new(&column_type, nullable); |
| 208 | if existing_rows > 0 { |
| 209 | col.backfill_nulls(existing_rows); |
| 210 | } |
| 211 | |
| 212 | self.columns.push(col); |
| 213 | let col_def = if nullable { |
| 214 | ColumnDef::nullable(name, column_type) |
| 215 | } else { |
| 216 | ColumnDef::required(name, column_type) |
| 217 | }; |
| 218 | self.schema.columns.push(col_def); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | /// Borrowed value for zero-copy ingest into the columnar memtable. |
nothing calls this directly
no test coverage detected