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.
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
Parameter | Type | Description |
---|---|---|
table | Table | The underlying |
key_cols optional | Union[str, List[str]] | The key column(s) of If |
unique_keys optional | bool | Whether the keys in If |
constituent_column optional | str | The constituent column name in If |
constituent_table_columns optional | List[Column] | The column definitions of the constituent table. If |
constituent_changes_permitted optional | bool | Whether the constituent tables can be changed. If |
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,
)
- source
- agg_table