make_resource

Type of operation: Metadata

Description

Creates a Resource dataset from an input Event dataset. make_resource must specify a primary key when the verb input dataset has none. If no primary key is specified, the input’s primary key will be used in the output. make_resource collapses adjacent events that contain the same primary key value and column values, and uses the first time such event is observed as Valid From. The end result is a dataset 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:

  1. the timestamp of the next distinct event

  2. Valid From + the expression optionally specified in validfor()

  3. 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 valid_for argument. If you can live with a constant maximum resource lifetime, using something like options(expiry:24h) is the most efficient option.

Note that make_resource cannot be used to directly convert a Table dataset to a Resource dataset. To do this, first convert the Table dataset to an Event dataset using make_event, and then you can use make_resource.

Usage

make_resource [ options ] [ , columnbinding ] ... [ , primarykey ] [ , validfor ]

Argument

Type

Required

Multiple

options

options

Optional

Only one

columnbinding

expression

Optional

Can be multiple

primarykey

primarykey

Optional

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)

From the input Event dataset, creates a Resource dataset 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))

From the input Event dataset, creates a Resource dataset with the primary key (pk1, pk2) and column col1 with an expiry period determined by column col2.

make_resource col1:col1

Assume the verb input is an Event dataset with a primary key (pk1, pk2) and additional columns col1 and col2. The above OPAL creates a Resource dataset with the primary key (pk1, pk2) and column col1 with the default 24-hour expiry period. Notice that the input primary key is propagated to the output, since there is no primary_key clause.

make_resource col1:col1, primary_key(pk1)

Assume the verb input is an Event dataset with a primary key (pk1, pk2) and additional columns col1 and col2. The above OPAL creates a Resource dataset with the primary key (pk1) and column col1 with the default 24-hour expiry period. Notice that the primary_key clause overrides the primary key of the verb’s input dataset.

Aliases

  • makeresource (deprecated)