The requirement is prepare the list of Products separated by '~' for each Customer ID. The sample data looks like below,
Input Data
Cust ID | Product |
101 | AA |
101 | AB |
101 | AC |
102 | AA |
102 | AC |
Output :
Cust ID | Product |
101 | AA~AB~AC |
102 | AA~AC |
Solution :
The ROOLUP is used with input SORTED data on Cust ID.
Delimited String Vector is defined and value is assigned to the same by using below functions.
let string("\x02", maximum_length=7) [unsigned long] vector_final;
vector_final = vector_sort_dedup_first(accumulation(in.product) , {machine descending} );
out.product:: string_join(vector_final, '~' );
accumulation : Returns a vector of input values. Available only within the ROLLUP and SCAN components.
vector_sort_dedup_first : Returns a new vector consisting of a sorted version of the input vector, which includes only the first element in each group of elements whose key matches the specified key.
string_join: Concatenates vector string elements into a single string.
Predefined sort sequence modifiers
DML supports the following predefined sort sequence modifiers: