Skip to main content
Version: Python


snapshot produces an in-memory copy of a source table that refreshes when another table, the trigger table, changes.


The trigger table is often a time table, a special type of table that adds new rows at a regular, user-defined interval. The sole column of a time table is Timestamp.


Columns from the trigger table appear in the result table. If the trigger and source tables have columns with the same name, an error will be raised. To avoid this problem, rename conflicting columns.


trigger.snapshot(source, doInitialSnapshot)



The table that triggers the snapshot.


The source table to snapshot.

  • true causes the snapshot to be created both when the trigger table ticks and when initially called.
  • false causes the snapshot to be created only when the trigger table ticks. The default value is false.


A snapshot of the source table that updates when the trigger table changes.


In the following example, the source table updates every 0.5 seconds with new data. The trigger table updates every five seconds, triggering a new snapshot of the source table (result). This design pattern is useful for reducing the amount of data that must be processed.

from deephaven import time_table
import random

source = time_table("00:00:00.5").update(formulas=["X = (int) random.randint(0, 100)", "Y = sqrt(X)"])

trigger = time_table("00:00:05").rename_columns(cols=["TriggerTimestamp = Timestamp"])

result = trigger.snapshot(source_table=source)

In the following example, a static snapshot of the source table is created at the instant snapshot is called.

First, create the dynamic source table.

from deephaven import time_table
import random

source = time_table("00:00:01").update(formulas=["X = (int) random.randint(0, 100)", "Y = sqrt(X)"])

Then, when desired, take a snapshot to freeze the dynamic table as a static table. empty_table creates a table that never changes. The doInitialSnapshot = True argument causes snapshot to create a snapshot without requiring the trigger table to first tick. The trigger table never changes so the snapshot will not change.

from deephaven import empty_table
result = empty_table(0).snapshot(source_table=source,do_init=True)