make_resource¶
Type of operation: Metadata
Description¶
Convert an event table to a resource with the specified primary key. Collapse adjacent events that contain the same primary key value and column values, and use the first time such event is observed as ‘valid_from’. The end result is a table that stores snapshots of the state of the observed entity, as a resource.
The ‘valid_to’ of the row is determined by the minimal of the following three things:
the timestamp of the next distinct event
‘valid_from’ + the expression optionally specified in validfor()
‘valid_from’ + the ‘expiry’ option value.
If an ‘expiry’ value is not provided, the default is 24 hours (86,400 seconds.)
Using the expiry
option costs less than using the more flexible validfor
argument. If you can live with a constant maximum resource lifetime, using
something like options(expiry:24h)
is the most efficient option.
Usage¶
make_resource [ options ], columnbinding ..., primarykey [ , validfor ]
Argument |
Type |
Required |
Multiple |
---|---|---|---|
options |
options |
Optional |
Only one |
columnbinding |
expression |
Required |
Can be multiple |
primarykey |
primarykey |
Required |
Only one |
validfor |
validfor |
Optional |
Only one |
Options¶
Option |
Type |
Meaning |
---|---|---|
expiry |
duration |
How long a resource lifetime is extended after an observed state change. |
Accelerable¶
make_resource is always accelerable if the input is accelerable. A dataset that only uses accelerable verbs, can be accelerated, making queries on the dataset respond faster.
Examples¶
make_resource options(expiry:duration_hr(1)), col1:col1, primary_key(pk1, pk2)
Produces a resource with the primary key (pk1, pk2) and column col1 with an expiry period of 1 hour.
make_resource col1:col1, primary_key(pk1, pk2), valid_for(duration(col2))
Produces a resource with the primary key (pk1, pk2) and column col1 with an expiry period determined by column col2.
Aliases¶
makeresource
(deprecated)