-
Type: New Feature
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: V4.0_CSD03
-
Fix Version/s: V4.0_CSD04
-
Component/s: Data Aggregation
-
Labels:None
-
Environment:
Applied
-
Proposal:
Transformation concat combines entity collections returned by two or more transformation sequences in a new, concatenated collection.
For limiting the number of items returned from the overall result collection, today the only way is to use system query options $skip and $top. It is currently not possible to limit the individual result collections of the transformation sequences passed to concat.
There are use cases requiring this ability. As an example, consider a request asking for (1) the grand total sales amount along with (2) the sales figures for the first 10 customers. Note that (1) may return a collection with more than one entry in case multiple currencies are involved, hence a global $top does not give full control to the client. In the worst case with more than ten currencies, not a single customer sales amount would be returned. If the aggregated result is put into a stable order with the orderby transformation (described in <issue>), this can be avoided with a top transformation:
GET ~/Sales?$apply=
concat( groupby( (Currency), Amount with sum as TotalAmount ),
groupby( (Customer,Currency), Amount with sum as TotalAmount )
/orderby( Customer,Currency )
/top( 10 )
)
Another example also involving a skip transformation could be a request fetching sales amounts per customer and month in pages of ten data points per request, complemented with minimum and maximum amounts of the entities on this page. The request for the fourth page would look like:
GET ~/Sales?$apply=
groupby( (Customer,Time/Month,Currency), Amount with sum as TotalAmount ),
/orderby( Customer,Time/Month,Currency )
/skip( 30 )/top( 10 )
/concat(
identity,
aggregate( Amount with min as MinAmount, Amount with max as MaxAmount ) )