sonar-delete-lookup-record-batch

Deletes records from the specified lookup table based on the key field value of the input record.

Command properties

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

Syntax

... | sonar-delete-lookup-record-batch lookup=STR

Options

lookup=STR
The name of the target lookup table to delete records from

Input fields

FieldTypeRequiredDescription
(the lookup schema's key field name)stringRequiredThe key value that identifies the record to delete. The field name must match the name of the first (key) field of the lookup table specified in the lookup option

Output fields

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

FieldTypeDescription
_errorstringThe error message if the record deletion failed

Error codes

Parsing errors
Error codeMessageDescription
300166No permission to add lookup records.Run by an account without administrator permission
300167Specify the lookup option.The lookup option was not specified
300168Lookup not found.No lookup table exists with the name given in lookup
Runtime errors

N/A

Description

For each input record, the sonar-delete-lookup-record-batch command reads the value of the field whose name matches the key field of the lookup table, and deletes the record for that key. The key field name is the same as the first field defined in the lookup schema.

If the key field value is missing (_error: key is null.) or is not a string type (_error: invalid key type.), the record is skipped and not processed. If no record exists in the lookup table for the key, key not found. is recorded in the _error field. These messages are always recorded in English regardless of locale.

If a record deletion fails at the database processing stage (for example, due to a SQL error), that failure is not recorded in the _error field. The command only receives this stage's failure as a return value and does not reflect it in the output record, so even if the _error field is empty, the record may not actually have been deleted. Query the lookup table directly to confirm whether the deletion actually took effect.

To insert new records, use the sonar-insert-lookup-record-batch command.

Examples

  1. Delete records from a lookup table

    json "[{'ip': '192.0.2.10'}, {'ip': '192.0.2.99'}]"
    | sonar-delete-lookup-record-batch lookup="asset-ip-map"
    

    Deletes the records from the asset-ip-map lookup table whose key matches the ip field value. For keys that do not exist, key not found. is recorded in the _error field.

Change history

The sonar-delete-lookup-record-batch 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. The Experimental app provides it under the name sonar-delete-lookup-records.