_catalog#
Contains classes for specifying schemas and constraints for tables.
Classes#
Metadata for a public or private table. |
|
Metadata for a public table. |
|
Metadata for a private table. |
|
Metadata for a view on a private table. |
|
Specifies schemas and constraints on public and private tables. |
- class Table#
Bases:
abc.ABC
Metadata for a public or private table.
- source_id :str#
The source id, or unique identifier, for the table.
- schema :tmlt.analytics._schema.Schema#
The analytics schema for the table. Describes the column types.
- class PublicTable#
Bases:
Table
Metadata for a public table.
Public tables contain information that is generally not sensitive and does not require any special privacy protections.
- source_id :str#
The source id, or unique identifier, for the table.
- schema :tmlt.analytics._schema.Schema#
The analytics schema for the table. Describes the column types.
- class PrivateTable#
Bases:
Table
Metadata for a private table.
Private tables contain sensitive information, such as PII, whose privacy has to be protected.
- stability :int#
The maximum number of rows a single individual can modify if they are modified.
This can become higher than 1 if there have been transformations, such as joins, which allow single individuals to affect many rows in the table.
- source_id :str#
The source id, or unique identifier, for the table.
- schema :tmlt.analytics._schema.Schema#
The analytics schema for the table. Describes the column types.
- class PrivateView#
Bases:
Table
Metadata for a view on a private table.
PrivateViews are similar to database views, which are extensions of the original tables. Information in a private view is private and needs to be protected.
- stability :int#
The maximum number of rows a single individual can modify if they are modified.
This can become higher than 1 if there have been transformations, such as joins, which allow single individuals to affect many rows in the table.
- source_id :str#
The source id, or unique identifier, for the table.
- schema :tmlt.analytics._schema.Schema#
The analytics schema for the table. Describes the column types.
- class Catalog#
Specifies schemas and constraints on public and private tables.
- __init__()#
Constructor.
- remove_table(self, source_id)#
Removes a table from the catalog.
- Parameters
source_id (str) – The name of the table.
- add_private_source(self, source_id, col_types, stability, grouping_column=None)#
Adds a private table to catalog. There may only be a single private table.
- Parameters
source_id (str) – The source id, or unique identifier, for the private table.
col_types (Mapping[str, Union[tmlt.analytics._schema.ColumnDescriptor, tmlt.analytics._schema.ColumnType]]) – Mapping from column names to types for private table.
stability (int) – The maximum number of rows that could be added or removed in the table if a single individual is added or removed.
grouping_column (Optional[str]) – Name of the column (if any) that must be grouped by in any groupby aggregations that use this table.
- Raises
RuntimeError – If there is already a private table.
- add_private_view(self, source_id, col_types, stability, grouping_column=None)#
Adds view table to catalog.
- Parameters
source_id (str) – The source id, or unique identifier, for the view table.
col_types (Mapping[str, Union[tmlt.analytics._schema.ColumnDescriptor, tmlt.analytics._schema.ColumnType]]) – Mapping from column names to types for private view.
stability (int) – The maximum number of rows that could be added or removed in the table if a single individual is added or removed.
grouping_column (Optional[str]) – Name of the column (if any) that must be grouped by in any groupby aggregations that use this table.
- add_public_source(self, source_id, col_types)#
Adds public table to catalog.
- Parameters
source_id (str) – The source id, or unique identifier, for the public table.
col_types (Mapping[str, Union[tmlt.analytics._schema.ColumnDescriptor, tmlt.analytics._schema.ColumnType]]) – Mapping from column names to types for the public table.
- property private_table(self)#
Returns the primary private table, if it exists.
- Return type
Optional[PrivateTable]