timeTable
The timeTable
method creates a time table that adds new rows at a specified interval. The resulting table has one date-time column, Timestamp
.
Syntax
timeTable(period)
timeTable(period, replayer)
timeTable(startTime, period)
timeTable(startTime, period, replayer)
timeTable(periodNanos)
timeTable(periodNanos, replayer)
timeTable(startTime, periodNanos)
timeTable(startTime, periodNanos, replayer)
timeTable(clock, startTime, periodNanos)
Parameters
Parameter | Type | Description |
---|---|---|
period | String | The time interval between new row additions. |
replayer | ReplayerInterface | Data replayer. |
startTime | DateTime | Start time for adding new rows. See the details on the |
periodNanos | long | The time interval between new rows in nanoseconds. |
clock | Clock | The clock. |
Returns
A ticking time table that adds new rows at the specified interval.
Example
The following example creates a time table that adds one new row every second.
result = timeTable("PT00:00:01")
The following example creates a time table that starts two hours prior to its creation.
startTime = minus(now(), parseDuration("PT2H"))
source = timeTable(startTime, "PT1S")
Details on the startTime
parameter
When no startTime
value is provided, the first entry in the time table will be "now" according to the internal system clock, rounded down to the nearest multiple of the period
based on the UTC epoch.
Critically, this is not necessarily the time that the function is initially called. Rather, it is the moment when the UG lock for the initial call is released. Consider an example that first calls timeTable
to create a ticking table, then does some other work that takes a significant amount of time. By executing this block of code all at once, a UG lock is held until it completes.
initial_execution_time = now()
t = timeTable("PT1s")
// do some work
sleep(5000)
It's reasonable to expect the first row of the ticking table to be within one second of initial_execution_time
. However, this is not the case.
t = t.snapshot().update("InitialExecutionTime = initial_execution_time")
- t
The first row of the ticking table is roughly 5 seconds ahead of the initial execution time of timeTable
. This is because the "work" the script performs with sleep
holds a lock on the UG, and that lock is not released until the work is complete. The table cannot start ticking until the lock is released, which happens roughly five seconds after timeTable
is initially called.