sqlmeta.objects.partition

Table Partition SQL Model.

Classes

Partition(name, table, partition_method[, ...])

Represents a table partition.

class sqlmeta.objects.partition.Partition(name: str, table: str, partition_method: str, partition_expression: str | None = None, partition_description: str | None = None, subpartitions: List[Partition] | None = None, schema: str | None = None, dialect: str | None = None, **kwargs: Any)[source]

Represents a table partition.

__init__(name: str, table: str, partition_method: str, partition_expression: str | None = None, partition_description: str | None = None, subpartitions: List[Partition] | None = None, schema: str | None = None, dialect: str | None = None, **kwargs: Any)[source]

Initialize a partition.

Parameters:
  • name – Partition name

  • table – Table name this partition belongs to

  • partition_method – Partition method (RANGE, LIST, HASH, KEY)

  • partition_expression – Expression used for partitioning

  • partition_description – Partition boundary description (VALUES LESS THAN, VALUES IN, etc.)

  • subpartitions – List of subpartitions (for composite partitioning)

  • schema – Schema name (optional)

  • dialect – SQL dialect

  • **kwargs – Additional dialect-specific metadata

property qualified_table_name: str

Get fully qualified table name.

Returns:

Qualified table name (schema.table)

property create_statement: str

Generate partition definition (part of ALTER TABLE or CREATE TABLE).

Note: Partitions are typically not created standalone, but as part of CREATE TABLE or ALTER TABLE statements.

Returns:

Partition definition clause

__str__() str[source]

Return string representation of the partition.

__eq__(other: Any) bool[source]

Check if two partitions are equal.

classmethod from_dict(data: Dict[str, Any]) Partition[source]

Create partition from dictionary representation.

Parameters:

data – Dictionary with partition attributes

Returns:

Partition object

to_dict() Dict[str, Any][source]

Convert partition to dictionary representation.

Returns:

Dictionary with partition attributes