transform

The transform method applies the supplied transformer to all constituent tables of a PartitionedTable and produces a new PartitionedTable containing the results.

The first overload records the enclosing ExecutionContext and opens it each time transformer runs, unless that context is systemic. The default context of a script session is systemic, so when this overload is called from the console, transformer must open an ExecutionContext itself before it uses the query language, as the first two examples below show. This overload expects transformer to produce refreshing results if and only if the underlying table of the PartitionedTable is refreshing.

The second overload opens the supplied ExecutionContext each time transformer runs and takes an explicit expectRefreshingResults flag.

Syntax

Parameters

ParameterTypeDescription
executionContextExecutionContext

The ExecutionContext in which to run transformer. If NULL, transform does not open an ExecutionContext for transformer.

transformerUnaryOperator<Table>

The operation to apply to each constituent table. It takes a table and returns a table. transformer must be stateless, safe for concurrent use, and able to return a valid result for an empty input table.

expectRefreshingResultsboolean

Whether to expect that the results of applying transformer may be refreshing. If true, the resulting PartitionedTable is always backed by a refreshing table. This hint is important for transforms of static inputs that might produce refreshing output, because it ensures correct liveness management. Incorrectly specifying false results in exceptions.

dependenciesNotificationQueue.Dependency...

Additional dependencies that must be satisfied before applying transformer to added or modified constituents during update processing. Use this when transformer uses additional Table or PartitionedTable inputs besides the constituents of this PartitionedTable.

Returns

A new PartitionedTable containing the results of applying transformer to all constituent tables.

Examples

The following example partitions a table by IntCol and applies a transformation that adds a new column, IntCol2, to each constituent. It then retrieves the constituent for key 3. The closure opens the script session's ExecutionContext before it calls update.

The following example partitions a table by Sym and applies aggregations to each constituent. It then retrieves the constituent for symbol A.

The following example applies the same aggregations as the previous example with the second overload. It passes the script session's ExecutionContext to transform, so the closure does not open a context itself. Because the source table is static and the aggregations do not produce refreshing results, it passes false for expectRefreshingResults.