sonar-clone-datasets

Clones the dataset corresponding to the guid passed in the input record. The name of the cloned dataset has a Copy of prefix added.

Command properties

PropertyDescription
Command typeProcessing query
Required permissionAdministrator
License usageN/A
Parallel executionNot supported
Distributed executionRuns on Data Node (mapper)

Syntax

... | sonar-clone-datasets [run=BOOL]

Options

[run=BOOL]
Specify t to actually clone the dataset. If not specified, nothing is actually cloned, and you can preview only the shape of the clone result record (default: f).

Input fields

FieldTypeRequiredDescription
guidstringRequiredThe GUID of the dataset to clone

Output fields

Returns all fields of the input record with the following fields added.

FieldTypeDescription
clone_guidstringThe GUID of the dataset to be newly created. Because this is a random value generated fresh each time the command is called, the value previewed without run can differ from the value actually issued when cloning with run=t. Not included in records where _error was recorded due to a missing guid field, a nonexistent target, or a clone failure during run=t
clone_namestringThe name of the dataset to be newly created (with the Copy of prefix). Like clone_guid, not included in records where _error was recorded
statusstringThe processing result, included only when run with run=t. success or failure
_errorstringThe error message if the clone failed

Error codes

Parsing errors
Error codeMessageDescription
300172No permission to list datasetsRun by an account without administrator permission
Runtime errors

N/A

Description

For each input record, the sonar-clone-datasets command looks up the target dataset by the guid field value, then prepares a clone with a new GUID and a name prefixed with Copy of. If the run option is not specified, nothing is actually cloned, and you can check only the shape of the clone result record. Because clone_guid is a random value generated fresh each time the command is called, the value you check at this point differs from the GUID that is actually issued when cloning with run=t. In practice, clone_name is the only value you can preview reliably. You must specify run=t to actually create the dataset, and the processing result is then recorded in the status field.

If the guid field is missing, guid field is required is recorded in the _error field; if the target dataset cannot be found, dataset not found is recorded, and the record is not cloned in either case. If the guid value is not in valid UUID format, query execution is aborted with an exception, so you must always provide a value in the same format as the guid output field of the sonar-datasets command.

Examples

  1. Find a dataset by name and preview the clone

    sonar-datasets
    | search name == "Monthly threat detection trend"
    | fields guid
    | sonar-clone-datasets
    

    Because the run option is not specified, nothing is actually cloned, and you can preview only the name of the dataset to be cloned. Because clone_guid is a value generated fresh each time the command is called, the GUID in this result cannot be used for the actual clone.

  2. Clone a dataset with a specific GUID

    json "[{'guid': '550e8400-e29b-41d4-a716-446655440002'}]"
    | sonar-clone-datasets run=t
    

    Actually clones the dataset with the specified GUID.

Change history

The sonar-clone-datasets command is available in the Sonar 4.0 series starting with 4.0.2609.0, where the command previously provided by the Experimental app was built into Sonar core. On versions without the built-in command, install the Experimental app to use it.