Richard Scott created NIFI-15628:
------------------------------------

             Summary: Add Expression Language function unique(delimiter) to 
return unique delimited values
                 Key: NIFI-15628
                 URL: https://issues.apache.org/jira/browse/NIFI-15628
             Project: Apache NiFi
          Issue Type: Improvement
          Components: NiFi API
            Reporter: Richard Scott


This function returns the *unique values* from a {*}delimited string{*}, 
{*}preserving the order of first occurrence{*}. The function takes a delimiter 
argument, splits the subject string on that delimiter, removes duplicate tokens 
while keeping the first occurrence, and joins the remaining tokens using the 
same delimiter.

*Subject Type:* String
*Arguments:*
 * {{delimiter}} (String): delimiter used to split and join the subject string

*Return Type:* String
h2. Use Case

Many flows produce list-like attributes (e.g., tags, labels, realms, paths, 
routing hops) that accumulate duplicates as processing continues. A built-in 
function to deduplicate while preserving the original order improves 
readability, consistency, and downstream matching without requiring scripting.
h2. Examples

If the {{tags}} attribute has value:
{{red,blue,red,green,blue,yellow}}
||Expression||Value||
|{{{}$\{tags:unique(','){}}}}|{{red,blue,green,yellow}}|
|{{{}$\{tags:unique(';'){}}}}|{{red,blue,red,green,blue,yellow}}|



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to