Schema¶
- pydantic model felis.datamodel.Schema¶
Database schema model.
This represents a database schema, which contains one or more tables.
- Parameters:
data (
Any
)- Fields:
- Validators:
check_tap_table_indexes
»all fields
check_unique_constraint_names
»all fields
check_unique_index_names
»all fields
generate_ids
»all fields
- field tables: Sequence[Table] [Required]¶
The tables in the schema.
- field version: SchemaVersion | str | None = None¶
The version of the schema.
- validator check_tap_table_indexes » all fields¶
Check that the TAP table indexes are unique.
- Parameters:
info (
ValidationInfo
) – The validation context used to determine if the check is enabled.- Returns:
The schema being validated.
- Return type:
- validator check_unique_constraint_names » all fields¶
Check for duplicate constraint names in the schema.
- Returns:
The schema being validated.
- Return type:
- Raises:
ValueError – Raised if duplicate constraint names are found in the schema.
- Parameters:
self (
Schema
)
- validator check_unique_index_names » all fields¶
Check for duplicate index names in the schema.
- Returns:
The schema being validated.
- Return type:
- Raises:
ValueError – Raised if duplicate index names are found in the schema.
- Parameters:
self (
Schema
)
- validator check_unique_table_names » tables¶
Check that table names are unique.
- Parameters:
- Returns:
The tables if they are unique.
- Return type:
- Raises:
ValueError – Raised if table names are not unique.
- dump_json(stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)¶
Pretty print the schema as JSON.
- dump_yaml(stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)¶
Pretty print the schema as YAML.
- find_object_by_id(id, obj_type)¶
Find an object with the given type by its ID.
- Parameters:
id (
str
) – The ID of the object to find.obj_type (
type
[TypeVar
(T
, bound=BaseObject
)]) – The type of the object to find.
- Returns:
The object with the given ID and type.
- Return type:
- Raises:
Notes
The actual return type is the user-specified argument
T
, which is expected to be a subclass ofBaseObject
.
- classmethod from_stream(source, context={})¶
Load a
Schema
from a file stream which should contain YAML data.- Parameters:
- Returns:
The Felis schema loaded from the stream.
- Return type:
- Raises:
yaml.YAMLError – Raised if there is an error loading the YAML file.
pydantic.ValidationError – Raised if the schema fails validation.
- classmethod from_uri(resource_path, context={})¶
Load a
Schema
from a string representing aResourcePath
.- Parameters:
resource_path (
str
|ParseResult
|ResourcePath
|Path
) – TheResourcePath
pointing to a YAML file.context (
dict
[str
,Any
], default:{}
) – Pydantic context to be used in validation.
- Returns:
The ID of the object.
- Return type:
- Raises:
yaml.YAMLError – Raised if there is an error loading the YAML data.
ValueError – Raised if there is an error reading the resource.
pydantic.ValidationError – Raised if the schema fails validation.
- validator generate_ids » all fields¶
Generate IDs for objects that do not have them.
- get_table_by_column(column)¶
Find the table that contains a column.
- Parameters:
column (
Column
) – The column to find.- Returns:
The table that contains the column.
- Return type:
- Raises:
ValueError – If the column is not found in any table.