[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: [OASIS Issue Tracker] (ODATA-1332) Support augmenting entities with aggregated values from related entities
Gerald Krause created ODATA-1332: ------------------------------------ Summary: Support augmenting entities with aggregated values from related entities Key: ODATA-1332 URL: https://issues.oasis-open.org/browse/ODATA-1332 Project: OASIS Open Data Protocol (OData) TC Issue Type: Improvement Components: Data Aggregation Affects Versions: V4.0_CS02 Reporter: Gerald Krause Fix For: V4.0_CSD04 For a collection of entities having navigation paths to related entities, adding an aggregated value from the related entities to each entity in the collection today requires a first argument to groupby listing all properties. For example, to retrieve all products together with their total sales amount: {{GET ~/Products?$apply=groupby((<key property>,<all other properties of type Category>),aggregate(Sales/Amount with sum as TotalAmount))}} returns all entities from the Products entity collection whose structure now also includes a dynamic property TotalAmount. If the underlying type comprises many properties, this approach becomes rather clumsy. Options to describe this request in a leaner way could be: A) Do the aggregation inside an expand transformation with a nested compute argument that operates on the entities of the navigation target. The determined result is then added to the result as expanded navigation property: {{GET ~/Products?$apply=expand(Sales,compute(aggregate(Amount with sum as TotalAmount)))}} returns {{{}} {{Â }}{{"@odata.context": "$metadata#Products",}} {{Â }}{{"value": [}} {{ÂÂÂ }}{{{ "ID": ..., "Name": ...", ...}} {{ÂÂÂÂÂ }}{{"Sales": [}} {{ÂÂÂÂÂÂÂ }}{{{ "Amount": ... }}}{{] },}} {{ÂÂÂ }}{{...}} {{Â ]}} {{}}} (this option requires an small extension of the proposal in ODATA-1244) B) Allow $it as first argument to groupby meaning that each entity of the input set becomes a separate subset on its own: {{GET ~/Products?$appy=groupby($it,aggregate(Sales/Amount with sum as TotalAmount))}} returns {{{}} {{Â "@odata.context": "$metadata#Products",}} {{Â }}{{"value": [}} {{ÂÂÂ }}{{{ "ID": ..., "Name": ...", ... "TotalAmount": ... }}}{{,}} {{ÂÂÂ }}{{...}} {{Â }}{{]}} {{}}} -- This message was sent by Atlassian JIRA (v7.7.2#77003)
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]