Skip to main content

set_key

The set_key processor is used to set the _key metadata value for any DataEntity or DataWindow.

Usage

Set the _key metadata from a field value

Example of a job that uses set_key processor

{
"name" : "testing",
"workers" : 1,
"slicers" : 1,
"lifecycle" : "once",
"assets" : [
"standard"
],
"operations" : [
{
"_op": "test-reader"
},
{
"_op": "set_key",
"field": "otherField"
}
]
}

Output of example job

const data = [
DataEntity.make({ name: 'chilly', otherField: 1 }),
DataEntity.make({ name: 'willy', otherField: 2 }),
DataEntity.make({ name: 'billy', otherField: 3 }),
DataEntity.make({ name: 'dilly', otherField: 4 }),
]

const results = await processor.run(data);

results[0].getKey() === 1
results[1].getKey() === 2
results[2].getKey() === 3
results[3].getKey() === 4

Parameters

ConfigurationDescriptionTypeNotes
_opName of operation, it must reflect the exact name of the fileStringrequired
fieldField name of value used to set keyStringoptional, defaults to _key