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
| Property | Description |
|---|---|
| Command type | Processing query |
| Required permission | Administrator |
| License usage | N/A |
| Parallel execution | Not supported |
| Distributed execution | Runs on Data Node (mapper) |
Syntax
Options
[run=BOOL]- Specify
tto 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
| Field | Type | Required | Description |
|---|---|---|---|
| guid | string | Required | The GUID of the dataset to clone |
Output fields
Returns all fields of the input record with the following fields added.
| Field | Type | Description |
|---|---|---|
| clone_guid | string | The 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_name | string | The name of the dataset to be newly created (with the Copy of prefix). Like clone_guid, not included in records where _error was recorded |
| status | string | The processing result, included only when run with run=t. success or failure |
| _error | string | The error message if the clone failed |
Error codes
Parsing errors
| Error code | Message | Description |
|---|---|---|
| 300172 | No permission to list datasets | Run 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
-
Find a dataset by name and preview the clone
sonar-datasets | search name == "Monthly threat detection trend" | fields guid | sonar-clone-datasetsBecause the
runoption is not specified, nothing is actually cloned, and you can preview only the name of the dataset to be cloned. Becauseclone_guidis a value generated fresh each time the command is called, the GUID in this result cannot be used for the actual clone. -
Clone a dataset with a specific GUID
json "[{'guid': '550e8400-e29b-41d4-a716-446655440002'}]" | sonar-clone-datasets run=tActually 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.