Concatenate Fields and Strings Together
Query
logscale
format("%s/%s",field=[dirname,filename],as=pathname)
Introduction
The concat()
is not able to concatenate
fields and strings together. For example to create a pathname
based on the directory and filename it is not possible to do:
logscale
concat([dirname,"/",filename],as=pathname)
This will raise an error. Instead, we can use
format()
.
Step-by-Step
Starting with the source repository events.
- flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] result{{Result Set}} repo --> 0 0 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;logscale
format("%s/%s",field=[dirname,filename],as=pathname)
Formats a value separating the two by a forward slash, creating the field pathname
Event Result set.
Summary and Results
The format()
function provides a flexible
method of formatting data, including encapsulating or combining
strings and fields together.