set_primary_key

Type of operation: Metadata

Description

Declare the primary key of the output as consisting of one or more named columns.

All rows with the same value in this column (or these columns) will be considered part of the same resource. This is a low-level function that will generate confusing results if not used as part of a larger context. It is recommended to instead use ‘make_resource’ or ‘update_resource’ or ‘timechart’ to go from event to resource, and ‘make_event’ to go from resource to event shape.

Note that time columns can be used as part of a primary key, and this can be a useful trick to produce resources that contain only one interval each.

Usage

set_primary_key columnname_1, columnname_2, ...

Argument

Type

Optional

Repeatable

Restrictions

columnname

variant

no

yes

column

Accelerable

set_primary_key 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

set_primary_key device_uid

Sets the primary key designation of the output dataset as the ‘device_uid’ field.

Aliases

  • set_pk

  • setpk (deprecated)