Any_non_null
Last updated
Last updated
Returns any non-null value from a list of input values, @param value is optional, if not specified, returns None when none of the listed values meet the criteria. Input must be a list (else treated as a single item list).
This function uses "from" as a parameter which is usually a comma separated list of column names. using which the first non null value will be picked. If all values are Nulls. value specified via default is used (optional)
Step 1: Create an empty any_non_null_example using AIOps studio as shown in the below screenshot
Step 2: Add the following pipeline code/commands into the above created pipeline as shown in the below screenshot:
You can copy the below code into your pipeline and execute that in your environment.
##### This pipeline creates set of records (ip_address, hostname, id)
##### using AIOps studio.
##### RDA function any_non_null is used to demo this example.
##### This function uses 'from' as a parameter which is a comma separated
##### list of column names (from dataset), using which the first non-null
##### value will be picked. If all the values are null in the selected
##### columns via from, function selects value specified in default token
@dm:empty
--> @dm:addrow ipaddress = '10.10.1.1' & hostname = 'host-1-1' & id = 'a1'
--> @dm:addrow ipaddress = '10.10.1.2' & id = 'a2'
--> @dm:addrow ipaddress = '10.10.1.3' & id = 'a3'
--> @dm:addrow hostname = 'host-4-4' & id = 'a4'
--> @dm:addrow id = 'a5'
--> @dm:map from = 'ipaddress,hostname' & to = 'ip_or_hostname' & func = 'any_non_null' & default = 'No IP_or_Hostname'
Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)
Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline with out any errors (as shown below)
Step 5: RDA uses the function 'any_non_null' and stores the data under 'ip_or_hostname' column. As explained earlier, this functions uses 'from' as a parameter which is a comma separated list of column names (from dataset), and using that the first non-null value will be picked/added to column data/value. If all the specified columns values are null, function substitutes the value given in the default token / value (as shown below).
Note: If user does not specify any default value parameters, RDA substitutes 'None' value as default in case of any empty values from the list of column names used via 'from'
You can copy the below code into your pipeline and execute that in your environment (in this example, default token is removed from the same pipeline and ran via RDA. Once RDA executes below pipeline, output is shown in below screen capture.
##### This pipeline creates set of records (ip_address, hostname, id)
##### using AIOps studio.
##### RDA function any_non_null is used to demo this example.
##### This function uses 'from' as a parameter which is a comma separated
##### list of column names (from dataset), using which the first non-null
##### value will be picked. If all the values are null in the selected
##### columns via from, function selects value specified in default token
@dm:empty
--> @dm:addrow ipaddress = '10.10.1.1' & hostname = 'host-1-1' & id = 'a1'
--> @dm:addrow ipaddress = '10.10.1.2' & id = 'a2'
--> @dm:addrow ipaddress = '10.10.1.3' & id = 'a3'
--> @dm:addrow hostname = 'host-4-4' & id = 'a4'
--> @dm:addrow id = 'a5'
--> @dm:map from = 'ipaddress,hostname' & to = 'ip_or_hostname' & func = 'any_non_null'