Uploaded image for project: 'OASIS Open Data Protocol (OData) TC'
  1. OASIS Open Data Protocol (OData) TC
  2. ODATA-1244

Add a function to determine aggregated values within common expressions

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.0_CS02
    • Fix Version/s: V4.0_CSD04
    • Component/s: Data Aggregation
    • Labels:
      None
    • Environment:

      Proposed

    • Proposal:
      Hide

      1.

      Add a new section before 3.16 Evaluating $apply to define a function aggregate that has a single parameter accepting an aggregate-function expression and returns the aggregated value of type Edm.PrimitiveType as the result from applying the aggregate expression on an input collection provided by the context.

      An aggregate-function expression offers the same capabilities as an aggregate expression defined for the aggregate transformation except that it does not support aggregation on related entities, and it never includes an alias for introducing a dynamic property containing the aggregated value.

      The function can be applied in any expression derived from the commonExpr rule (see **[OData-ABNF]). Within $apply, the function is applied as part of an argument expression to a transformation, and the input set of that transformation is the input collection for the function. Outside of $apply, the function may be applied in requests querying collections in an argument expression for a system query option and a lambda operator. Inside a system query option, the collection on which it operates is used as input collection for the function. This is also valid for nested query options used as arguments, like $filter in $expand. Inside a lambda predicate expression the input collection for the aggregate function depends on the path expression used in the aggregateFunctionExpr (see ABNF below): For a path expression starting with the lambda variable the input collection is given by the target of the navigation path prepended to the lambda operator; for a path expression starting with $it the collection addressed by the resource path is the input collection; for other path expressions the input collection is given by the collection of instances at the origin of the navigation path prepended to the lambda operator.

       

      2.
      In the Data Aggregation’s ABNF, define the rule for computeAggregateMethodCallExpr as

      aggregateMethodCallExpr = 'aggregate' OPEN BWS aggregateFunctionExpr BWS CLOSE 
      
      aggregateFunctionExpr   = '$count'
                              / commonExpr aggregateWith [ aggregateFrom ]
                              / / [ inscopeVariableExpr "/" ] pathPrefix primitiveProperty aggregateWith [ aggregateFrom ]
                              / / [ inscopeVariableExpr "/" ] pathPrefix customAggregate [ aggregateFrom ]
      

      Add the aggregateMethodCallExpr rule to the set of rules recognized by methodCallExpr within a commonExpr:

      methodCallExpr =/ aggregateMethodCallExpr
      
      Show
      1. Add a new section before 3.16 Evaluating $apply to define a function aggregate that has a single parameter accepting an aggregate-function expression and returns the aggregated value of type Edm.PrimitiveType as the result from applying the aggregate expression on an input collection provided by the context. An aggregate-function expression offers the same capabilities as an aggregate expression defined for the aggregate transformation except that it does not support aggregation on related entities, and it never includes an alias for introducing a dynamic property containing the aggregated value. The function can be applied in any expression derived from the commonExpr rule (see ** [OData-ABNF] ). Within $apply, the function is applied as part of an argument expression to a transformation, and the input set of that transformation is the input collection for the function. Outside of $apply, the function may be applied in requests querying collections in an argument expression for a system query option and a lambda operator. Inside a system query option, the collection on which it operates is used as input collection for the function. This is also valid for nested query options used as arguments, like $filter in $expand. Inside a lambda predicate expression the input collection for the aggregate function depends on the path expression used in the aggregateFunctionExpr (see ABNF below): For a path expression starting with the lambda variable the input collection is given by the target of the navigation path prepended to the lambda operator; for a path expression starting with $it the collection addressed by the resource path is the input collection; for other path expressions the input collection is given by the collection of instances at the origin of the navigation path prepended to the lambda operator.   2. In the Data Aggregation’s ABNF, define the rule for computeAggregateMethodCallExpr as aggregateMethodCallExpr = 'aggregate' OPEN BWS aggregateFunctionExpr BWS CLOSE  aggregateFunctionExpr   = '$count' / commonExpr aggregateWith [ aggregateFrom ]                         / / [ inscopeVariableExpr "/" ] pathPrefix primitiveProperty aggregateWith [ aggregateFrom ] / / [ inscopeVariableExpr "/" ] pathPrefix customAggregate [ aggregateFrom ] Add the aggregateMethodCallExpr rule to the set of rules recognized by methodCallExpr within a commonExpr: methodCallExpr =/ aggregateMethodCallExpr
    • Resolution:
      Show
      https://github.com/oasis-tcs/odata-abnf/pull/11  

      Description

      Currently, there is no possibility to combine values of a single entity with an aggregated value determined from the input set in a single calculation. Expressions passed to the compute transformation always operate on properties of the individual entities in the input set. This prevents use cases like calculating the ratio of an entity's property value to an aggregated value from the input set. Examples for ratio calculations can be found in ODATA-947

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gerald.krause1 Gerald Krause
            • Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: