Seven Stars

[resolved] Does tAggregateRow preserve the sort order of the flow?

Does tAggregateRow preserve the sort order of the input flow in all cases?
For example, will the following input:
MbrID|RowID|Value
1|1|A
1|2|B
1|3|C
2|1|D
2|2|E
when aggregating the third field as a list, always result in the following output:
MbrID|Values
1|A,B,C
2|D,E
or might the order of the values be changed?
It appears that the list function of tAggregateRow achieves the same result as tDenormalize (although with less flexibility i.e. cannot merge values or specify delimiter). However, tDenormalize has a warning that "the component may change input order".
Note that I do not want to use tAggregateSortedRow because of the difficulty of obtaining the required "input row count" resulting from my very complex mappings.
Thanks!
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] Does tAggregateRow preserve the sort order of the flow?

Hello
Does tAggregateRow preserve the sort order of the flow?

Yes, tAggregateRow doesn't preserve the order of the flow eg:
1|1|A
1|2|C
1|3|B
2|1|D
2|2|E
3|1|B
3|2|A
4|1|B
4|2|A
o/p:
3|B,A
4|B,A
1|A,C,B
2|D,E
Normally, it need a tSortRow component after tAggregateRow to sort the rows.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
6 REPLIES
Community Manager

Re: [resolved] Does tAggregateRow preserve the sort order of the flow?

Hello
Does tAggregateRow preserve the sort order of the flow?

Yes, tAggregateRow doesn't preserve the order of the flow eg:
1|1|A
1|2|C
1|3|B
2|1|D
2|2|E
3|1|B
3|2|A
4|1|B
4|2|A
o/p:
3|B,A
4|B,A
1|A,C,B
2|D,E
Normally, it need a tSortRow component after tAggregateRow to sort the rows.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seven Stars

Re: [resolved] Does tAggregateRow preserve the sort order of the flow?

Thanks, Shong.
So the order of the records ("grouped by" fields) is not preserved. What about the order of the values in the "listed" field?
I.e. might the output from your input be, for example:
3|B,A
4|A,B
1|A,B,C
2|D,E
Community Manager

Re: [resolved] Does tAggregateRow preserve the sort order of the flow?

Hello
What about the order of the values in the "listed" field?

It always preserves the order of value of list.Smiley Wink
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seven Stars

Re: [resolved] Does tAggregateRow preserve the sort order of the flow?

Great! Thanks
Seven Stars

Re: [resolved] Does tAggregateRow preserve the sort order of the flow?

Sorry, I do have a further question:
If tAggregateRow groups on the first two fields in the following example and lists the fourth field, is the order of the second field relative to the first field preserved?
Input:
1|1|1|A
1|1|2|B
1|1|3|C
1|2|1|F
1|2|2|D
1|2|3|E
2|1|1|D
2|1|2|E
2|2|1|F
2|2|2|G
3|1|1|B
3|1|2|A
3|2|1|C
3|2|2|D
4|1|1|D
4|1|2|C
4|2|1|A
4|2|2|B
Output1:
3|1|B,A
3|2|C,D
4|1|D,C
4|2|A,B
1|1|A,B,C
1|2|F,D,E
2|1|D,E
2|2|F,G
or output2:
4|2|A,B
3|1|B,A
4|1|D,C
2|2|F,G
1|1|A,B,C
3|2|C,D
1|2|F,D,E
2|1|D,E
Thanks
Community Manager

Re: [resolved] Does tAggregateRow preserve the sort order of the flow?

Hello
is the order of the second field relative to the first field preserved?

No, this component doesn't preserve the order of columns which are group key and sort the rows.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business