Skip to main content
Version: Python

from_partitioned_table

The from_partitioned_table method creates a new PartitionedTable from an underlying partitioned table with specifications such as which key columns to include, whether to allow changes to constituent tables, and more. It is a class method, meaning it can be called on both an instance of a class, or the class itself.

danger

The key_cols, unique_keys, constituent_column, constituent_table_columns, and constituent_changes_permitted parameters either must all be None, or must all have values.

Syntax

PartitionedTable.from_partitioned_table(
table: Table,
key_cols: Union[str, List[str]] = None,
unique_keys: bool = None,
constituent_column: str = None,
constituent_table_columns: List[Column] = None,
constituent_changes_permitted: bool = None,
) -> PartitionedTable

Parameters

ParameterTypeDescription
tableTable

The underlying PartitionedTable.

key_cols optionalUnion[str, List[str]]

The key column(s) of table.

If None, the names of all columns with a non-Table data type will be used as key columns.

unique_keys optionalbool

Whether the keys in table are guaranteed to be unique.

If None, the value defaults to False.

constituent_column optionalstr

The constituent column name in table.

If None, the value defaults to the name of the first column with a Table data type (usually __CONSTITUENT__).

constituent_table_columns optionalList[Column]

The column definitions of the constituent table.

If None, the value defaults to the column definitions of the first cell (constituent table) in the constituent column. Consequently, the constituent column cannot be empty.

constituent_changes_permitted optionalbool

Whether the constituent tables can be changed.

If None, the value defaults to the result of table.is_refreshing.

Returns

A PartitionedTable.

Example

The following example uses from_partitioned_table to construct a partitioned table from an underlying partitioned table (agg_table). It calls the method on the PartitionedTable class itself, and sets each of the optional input parameters.

from deephaven.table import PartitionedTable
from deephaven import empty_table
from deephaven import agg

source = empty_table(50).update(["X=i", "Y=i%13", "Z=X*Y"])

pt = source.partition_by("Y")

agg_partition = agg.partition("aggPartition")
agg_table = source.agg_by(agg_partition, ["Y"])
new_pt = PartitionedTable.from_partitioned_table(
table=agg_table,
key_cols="Y",
unique_keys=True,
constituent_column="aggPartition",
constituent_table_columns=source.columns,
constituent_changes_permitted=True,
)