_truncation#

Defines constraints which result in truncations.

These constraints all in some way limit how many distinct values or repetitions of the same value may appear in a column, often in relation to some other column.

Functions#

simplify_truncation_constraints()

Remove redundant truncation constraints from a list of constraints.

simplify_truncation_constraints(constraints)#

Remove redundant truncation constraints from a list of constraints.

Parameters

constraints (List[tmlt.analytics.constraints._base.Constraint]) –

Return type

List[tmlt.analytics.constraints._base.Constraint]

Classes#

MaxRowsPerID

A constraint limiting the number of rows associated with each ID in a table.

MaxGroupsPerID

A constraint limiting the number of distinct groups per ID.

MaxRowsPerGroupPerID

A constraint limiting rows per unique (ID, grouping column) pair in a table.

class MaxRowsPerID#

Bases: tmlt.analytics.constraints._base.Constraint

A constraint limiting the number of rows associated with each ID in a table.

This constraint limits how many times each distinct value may appear in the ID column of a table with the AddRowsWithID protected change. For example, MaxRowsPerID(5) guarantees that each ID appears in at most five rows. It cannot be applied to tables with other protected changes.

max :int#

The maximum number of times each distinct value may appear in the column.

class MaxGroupsPerID#

Bases: tmlt.analytics.constraints._base.Constraint

A constraint limiting the number of distinct groups per ID.

This constraint limits how many times a distinct value may appear in the grouping column for each distinct value in the table’s ID column. For example, MaxGroupsPerID("grouping_column", 4) guarantees that there are at most four distinct values of grouping_column for each distinct value of ID_column.

grouping_column :str#

The name of the grouping column.

max :int#

The maximum number of distinct values in the grouping column for each distinct value in the ID column.

class MaxRowsPerGroupPerID#

Bases: tmlt.analytics.constraints._base.Constraint

A constraint limiting rows per unique (ID, grouping column) pair in a table.

For example, MaxRowsPerGroupPerID("group_col", 5) guarantees that each ID appears in at most five rows for each distinct value in group_col.

grouping_column :str#

Name of column defining the groups to truncate.

max :int#

The maximum number of times each distinct value may appear in the column.