TopK / Manipulation Layer
Select the top K rows after sorting by specified column(s). Similar to pandas' nlargest() or SQL's ORDER BY with LIMIT.
Key features:
- Multi-column sorting support
- Flexible null handling
- Order preservation options
Common applications:
- Best performers identification
- High-value transaction analysis
- Top percentile selection
- Premium customer identification
- Peak detection in time series
Example: With K=10, find top 10 sales representatives by revenue, or highest-rated products by customer satisfaction.
Table
0
0
Table
SortBy
[, ...]Ordered list of columns defining the sort criteria. Multiple columns enable:
- Primary and secondary rankings
- Composite scoring
- Tie-breaking rules Example: sort by revenue, then by customer satisfaction for equal revenue.
Select
columnColumn to use in sort criteria. Examples:
- Revenue or profit figures
- Performance metrics
- Quality scores
- Customer ratings Multiple columns create a hierarchical sort order.
Descending
boolControls sort direction for this column:
false
(default): Ascending (smallest first)true
: Descending (largest first) Example: true for highest sales, false for fastest times.
K
u32Number of top rows to select. Examples:
- 10 highest-value customers
- 5 best-selling products
- 20 most recent transactions Must be positive and not exceed total row count.
NullsLast
boolControls null value placement in sort order:
false
(default): Nulls considered firsttrue
: Nulls placed at end Important for handling missing data in rankings.
MaintainOrder
boolControls stability of sort within equal values:
false
(default): May reorder equal valuestrue
: Preserves original order of equal values Important for reproducible rankings and audit trails.