strcat
Definition
strcat
combines string values from two or more table columns into one. The command requires at least two columns for combining, a destination column name and one or more separator strings.
Syntax
| strcat [allrequired=<boolean>] <column-name> "<separator-string>" <column-name> <destination-column>
Examples
Use strcat
to combine values from different columns into one. The following example combines values from operation and success columns into a new column called operationSuccess. It also adds a slash between combined values.
%dpl
index=crud earliest=-5y
| spath
| strcat operation " / " success operationSuccess

Combine values from multiple columns
You can combine values from more than two columns into one column. Keep in mind that the last column name in the list is always the destination column where combined values go.
The following example combines values from operation, success, and count columns into a new column called operationSuccessCount. It also adds slashes between combined values.
%dpl
index=crud earliest=-5y
| spath
| strcat operation " / " success " / " count operationSuccessCount

Combine values into existing column
If the destination column has the same name as existing column, strcat
overwrites the existing column’s values with combined values.
%dpl
index=crud earliest=-5y
| spath
| strcat operation " / " success operation

Separator string
At least one separator string is always required with strcat
command. You can place it between all column values or only some. The following example has a slash only between operation and success columns.
%dpl
index=crud earliest=-5y
| spath
| strcat operation " / " success count operationSuccessCount

However, if you don’t want to use a separating string between values, you can leave it empty.
%dpl
index=crud earliest=-5y
| spath
| strcat operation success count "" operationSuccessCount

allrequired
allrequired
defines if all listed columns must have values in each row before they’re combined in the destination column. It takes a boolean value and by default it’s set to FALSE
.
If allrequired
is set to FALSE
, it treats empty or non-existing columns as empty strings. The following example combines operation, count, extra, and elapsed columns into a new column called combined. Values are separated with slashes.
index=crud earliest=-5y
| spath
| strcat allrequired=false operation " / " count " / " extra " / " elapsed combined

If allrequired
is set to TRUE
, values are written to the destination column only if all listed columns exist. The following example is otherwise the same as the previous one, but this time values aren’t returned since extra named column doesn’t have values because it doesn’t exist.
index=crud earliest=-5y
| spath
| strcat allrequired=true operation " / " count " / " extra " / " elapsed combined
