tlc.core.operations.operation

This module provides an 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

CalculateValueContext

Represents the context in which a value is calculated.

CalculateSchemaContext

Represents the context in which a schema is calculated.

Operation

An abstract base class representing a generic operation on data.

LocalOperation

An abstract base class representing a local operation on data.

GlobalOperation

An abstract base class representing a global operation on data.

API

class tlc.core.operations.operation.CalculateValueContext(table: tlc.core.objects.table.Table, input_table_schemas: dict[str, tlc.core.schema.Schema])

Represents the context in which a value is calculated.

class tlc.core.operations.operation.CalculateSchemaContext(input_table_row_schemas: dict[str, tlc.core.schema.Schema])

Represents the context in which a schema is calculated.

class tlc.core.operations.operation.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: tlc.core.operations.operation.CalculateSchemaContext) tlc.core.schema.Schema

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

abstract populate_column_data(calculate_value_context: tlc.core.operations.operation.CalculateValueContext) list[Any]

Populate column data based on the operation and input table.

column_name() str

Generate a unique column name based on the object id.

class tlc.core.operations.operation.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: collections.abc.Mapping[str, object], calculate_value_context: tlc.core.operations.operation.CalculateValueContext) object

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

populate_column_data(calculate_value_context: tlc.core.operations.operation.CalculateValueContext) list[object]

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

class tlc.core.operations.operation.GlobalOperation

Bases: tlc.core.operations.operation.Operation

An abstract base class representing a global operation on data.

Acts on entire columns of data.