| 209 | properties: Optional[Dict[str, str]] = None |
| 210 | |
| 211 | def build(self) -> 'Table': |
| 212 | result = Table( |
| 213 | name=self.name, |
| 214 | schema=self.schema, |
| 215 | alias=self.alias, |
| 216 | note=self.note.build() if self.note else None, |
| 217 | header_color=self.header_color, |
| 218 | comment=self.comment, |
| 219 | properties=self.properties |
| 220 | ) |
| 221 | columns = self.columns or [] |
| 222 | indexes = self.indexes or [] |
| 223 | for col_bp in columns: |
| 224 | result.add_column(col_bp.build()) |
| 225 | for index_bp in indexes: |
| 226 | index = index_bp.build() |
| 227 | new_subjects: List[Union[str, Column, Expression]] = [] |
| 228 | for subj in index_bp.subject_names: |
| 229 | if isinstance(subj, ExpressionBlueprint): |
| 230 | new_subjects.append(subj.build()) |
| 231 | else: |
| 232 | for col in result.columns: |
| 233 | if col.name == subj: |
| 234 | new_subjects.append(col) |
| 235 | break |
| 236 | else: |
| 237 | raise ColumnNotFoundError( |
| 238 | f'Cannot add index, column "{subj}" not defined in' |
| 239 | ' table "{self.name}".' |
| 240 | ) |
| 241 | index.subjects = new_subjects |
| 242 | result.add_index(index) |
| 243 | return result |
| 244 | |
| 245 | def get_reference_blueprints(self): |
| 246 | ''' the inline ones ''' |