tlc.core.operations.operation¶

Abstract base class for operations and its specialized subclasses.

The Operation class serves as an abstract base class for different types of operations that can be applied to tables.

  • Operation: Abstract base class for table operations.

  • LocalOperation: Specialized class for operations acting on individual rows.

  • GlobalOperation: Specialized class for operations acting on entire columns.

Module Contents¶

Classes¶

Class

Description

CalculateSchemaContext

Represents the context in which a schema is calculated.

CalculateValueContext

Represents the context in which a value is calculated.

GlobalOperation

An abstract base class representing a global operation on data.

LocalOperation

An abstract base class representing a local operation on data.

Operation

An abstract base class representing a generic operation on data.

API¶

class CalculateSchemaContext(
input_table_row_schemas: dict[str, Schema],
)¶

Represents the context in which a schema is calculated.

class CalculateValueContext(
table: Table,
input_table_schemas: dict[str, Schema],
)¶

Represents the context in which a value is calculated.

class GlobalOperation¶

Bases: tlc.core.operations.operation.Operation

An abstract base class representing a global operation on data.

Acts on entire columns of data.

class LocalOperation¶

Bases: tlc.core.operations.operation.Operation

An abstract base class representing a local operation on data.

Subclasses must implement the calculate_single_value method.

abstract calculate_single_value(
row: Mapping[str, object],
calculate_value_context: CalculateValueContext,
) object¶

Calculate a single value for a row based on the operation.

populate_column_data(
calculate_value_context: CalculateValueContext,
) list[object]¶

Populate a list of values for a new column in the table.

class Operation¶

Bases: abc.ABC

An abstract base class representing a generic operation on data.

Subclasses must implement the calculate_schema as well as either populate_column_data for global operations or calculate_single_value for local operations.

abstract calculate_schema(
calculate_schema_context: CalculateSchemaContext,
) Schema¶

Calculate the schema for the resulting table based on input schemas.

column_name() str¶

Generate a unique column name based on the object id.

abstract populate_column_data(
calculate_value_context: CalculateValueContext,
) list[Any]¶

Populate column data based on the operation and input table.