| 481 | } |
| 482 | |
| 483 | pub fn build_schema(&self, columns: Vec<SQLColumnDef>) -> Result<Schema> { |
| 484 | let mut fields = Vec::with_capacity(columns.len()); |
| 485 | |
| 486 | for column in columns { |
| 487 | let data_type = self.convert_data_type_to_field(&column.data_type)?; |
| 488 | let not_nullable = column |
| 489 | .options |
| 490 | .iter() |
| 491 | .any(|x| x.option == ColumnOption::NotNull); |
| 492 | fields.push( |
| 493 | data_type |
| 494 | .as_ref() |
| 495 | .clone() |
| 496 | .with_name(self.ident_normalizer.normalize(column.name)) |
| 497 | .with_nullable(!not_nullable), |
| 498 | ); |
| 499 | } |
| 500 | |
| 501 | Ok(Schema::new(fields)) |
| 502 | } |
| 503 | |
| 504 | /// Returns a vector of (column_name, default_expr) pairs |
| 505 | pub(super) fn build_column_defaults( |