369 def from_felis(cls, dm_table: felis.datamodel.Table, columns: Mapping[str, Column]) -> Table:
370 """Convert Felis table definition into instance of this class.
371
372 Parameters
373 ----------
374 dm_table : `felis.datamodel.Table`
375 Felis table definition.
376 columns : `~collections.abc.Mapping` [`str`, `Column`]
377 Mapping of column ID to `Column` instance.
378
379 Returns
380 -------
381 table : `Table`
382 Converted table definition.
383 """
384 table_columns = [columns[c.id] for c in dm_table.columns]
385 if dm_table.primary_key:
386 pk_columns = [columns[c] for c in _make_iterable(dm_table.primary_key)]
387 else:
388 pk_columns = []
389 constraints = [Constraint.from_felis(constr, columns) for constr in dm_table.constraints]
390 indices = [Index.from_felis(dm_idx, columns) for dm_idx in dm_table.indexes]
391 table = cls(
392 name=dm_table.name,
393 id=dm_table.id,
394 columns=table_columns,
395 primary_key=pk_columns,
396 constraints=constraints,
397 indexes=indices,
398 description=dm_table.description,
399 annotations=_strip_keys(
400 dict(dm_table),
401 ["name", "id", "columns", "primaryKey", "constraints", "indexes", "description"],
402 ),
403 )
404 return table
405
406
407@dataclasses.dataclass