Skip to main content

copy_field

The copy_field processor copies the source field value to a destination field for any DataEntity or DataWindow.

Usage

Copy a field value to another field

Example of a job using the copy_field processor

{
"name" : "testing",
"workers" : 1,
"slicers" : 1,
"lifecycle" : "once",
"assets" : [
"standard"
],
"operations" : [
{
"_op": "test-reader"
},
{
"_op": "copy_field",
"source": "name",
"destination": "name_again"
}
]
}

Example of the data and the expected results

const data = [
DataEntity.make({ name: 'lilly', 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);

DataEntity.make({ name: 'lilly', name_again: 'lilly', otherField: 1 }),
DataEntity.make({ name: 'willy', name_again: 'willy', otherField: 2 }),
DataEntity.make({ name: 'billy', name_again: 'billy', otherField: 3 }),
DataEntity.make({ name: 'dilly', name_again: 'dilly', otherField: 4 }),

Parameters

ConfigurationDescriptionTypeNotes
_opName of operation, it must reflect the exact name of the fileStringrequired
sourceName of field to copy the value fromStringrequired, no default
destinationName of field to copy the value toStringrequired, no default
delete_sourceOption to delete the source field once the value is copied to the destination fieldBooleanoptional, defaults to false