Table operations overview
This page is a quick-reference index of common table operations in Deephaven. Find your task in the table, then follow the link to the operation's reference page for its syntax and examples.
These operations work on static tables and on real-time tables that tick. When the source data changes, their results update with it. A few have restrictions. rangeJoin supports only static tables. Some operations, such as groupBy, raise an error on blink tables. Aggregations on blink tables cover every row since the aggregation started, not only the current cycle's rows. See specialized semantics for blink tables.
To learn a group of operations by task, see the how-to guides:
- Filter table data
- Select and create columns
- Drop, move, and rename columns
- Sort table data
- Exact and relational joins
- Inexact, time-series, and range joins
- Group and ungroup data
- Single aggregation
- Multi-aggregation
- Rolling aggregations
- Merge tables
- Synchronize multiple tables
To choose from the aggregation operations, see Aggregations in Deephaven. To learn the concepts behind table operations, such as immutability, formula strings, and the dependency graph, see Understanding the Table API. For formulas in depth, see Formulas.
Quick reference
| I want to... | Use this |
|---|---|
| Keep rows matching a condition | where("condition") |
| Keep rows whose key values appear, or don't appear, in another table | whereIn(filterTable, "Key") / whereNotIn(filterTable, "Key") |
Get the first or last n rows | head(n) / tail(n) |
| Add columns (stored in memory) | update("NewColumn = formula") |
| Add columns (computed on demand) | updateView("NewColumn = formula") |
| Keep or compute specific columns (stored in memory), dropping the rest | select("Column1", "NewColumn = formula") |
| Keep or compute specific columns (computed on demand), dropping the rest | view("Column1", "NewColumn = formula") |
| Remove columns | dropColumns("Column1") |
| Rename columns | renameColumns("NewName = OldName") |
| Sort by column | sort("Column") |
| Sort in descending order | sortDescending("Column") |
| Add columns from a lookup table (at most one match per row, null if no match) | naturalJoin(other, "Key", "AddedColumn") |
| Add columns from a table where every row must have exactly one match | exactJoin(other, "Key", "AddedColumn") |
| Join every matching row, or cross join with no key | join(other, "Key") |
| Match on a timestamp or other ordered key (closest at or before) | aj(other, "Key, Timestamp", "AddedColumn") |
| Match on a timestamp or other ordered key (closest at or after) | raj(other, "Key, Timestamp", "AddedColumn") |
| Group right-table values that fall in a range (static tables only) | rangeJoin(other, ["Key", "Start <= Timestamp <= End"], [AggGroup(...)]) |
| Apply one aggregation to every non-key column, per group | sumBy("Key") (also avgBy, maxBy, minBy, and similar dedicated aggregations) |
| Count the rows in each group | countBy("Count", "Key") |
| Apply different aggregations to different columns, per group | aggBy([AggSum(...)], "Key") |
| Collect each group's values into arrays, or expand arrays back into rows | groupBy("Key") / ungroup() |
| Compute cumulative or rolling values | updateBy([CumSum(...)], "Key") |
| Stack tables on top of each other | merge(table1, table2) |
Most entries are methods on a table. merge is a static method. AggSum and AggGroup, which create aggregations, are static methods too. CumSum, which creates an update-by operation, is also a static method. Deephaven's Groovy sessions import these static methods by default, so your code needs no import statement.
Diving deeper: API references
For the full interface definitions and operation contracts, see the generated API documentation:
- The Javadoc for
Tabledescribes the interface and all of its methods. - The Javadoc for
TableOperationsgives the operation contracts that define behavior.
Each operation's reference page, such as where or update, also links to the relevant Javadoc.
A quick reference for table operations