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

Rephrase definitions for any, all and aggregate

    XMLWordPrintable

    Details

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

      Applied

    • Proposal:
      Hide
      • The aggregate function is considered a collectionPathExpr (rather than a methodCallExpr) and must be prepended with a navigation path that addresses the input collection (in the sense of ODATA-1244). In the argument of the aggregation function, common expressions are evaluated according to the rules for lambda operators. (The lambda variable evaluates to the current instance within the addressed collection, whereas an unprefixed Amount would be evaluated in the context of the Products instance currently being filtered.)
        Products?$filter=Sales/aggregate(s:s/Amount mul TaxRate with sum) gt 100
      • Instead of a navigation path, the input collection can also be addressed by the keyword $these. A new kind of propertyPathExpr is introduced in which $these addresses the "current collection" (defined below), in analogy with the current instance $this [OData-URL, section 5.1.1.14.6]. The current collection is also at the origin of the path $these, therefore s/Amount could be replaced by Amount in the following example.
        Sales?$apply=groupby((Product),filter($these/aggregate(s:s/Amount) lt 100))
      • $these can be prepended to collection path expressions like any, all and aggregate. (But we allow only $these/aggregate for now, so as not to touch the core spec.) See also ODATA-1456.
      • In a system query option (possibly nested within $expand or $select), when evaluating the boolCommonExpr in a filter or the commonExpr in an orderbyItem or computeItem, the current collection is the collection being filtered or ordered or augmented.
        Products?$select=Sales($filter=$these/aggregate(s:Price with avg) gt $this/Price)
        
      • In an $apply transformation, when evaluating the boolCommonExpr in a filterTrafo or the commonExpr in a computeExpr, the current collection is the input set of the transformation.
      • When evaluating a commonExpr in its nearest collectionPathExpr, the current collection is the collection identified by the navigation path before the collectionPathExpr. This allows things like
        Products?$filter=Sales/any(p:p/Amount gt $these/aggregate(q:Amount))
        

      See also oasis-tcs/odata-abnf#37.

      The third paragraph in [OData-Aggr, section 3.24 "Function aggregate"] must be rewritten to reflect the rules above. The $these keyword and "current collection" concept introduced in these rules are not mentioned outside of that section for now. See https://www.oasis-open.org/apps/org/workgroup/odata/download.php/69074/ODATA-1451.docx

      Show
      The aggregate function is considered a  collectionPathExpr  (rather than a methodCallExpr ) and must be prepended with a navigation path that addresses the input collection (in the sense of ODATA-1244 ). In the argument of the aggregation function, common expressions are evaluated according to the rules for lambda operators . (The lambda variable evaluates to the current instance within the addressed collection, whereas an unprefixed Amount would be evaluated in the context of the Products instance currently being filtered.) Products?$filter=Sales/aggregate(s:s/Amount mul TaxRate with sum) gt 100 Instead of a navigation path, the input collection can also be addressed by the keyword  $these . A new kind of  propertyPathExpr  is introduced in which  $these addresses the "current collection" (defined below), in analogy with the current instance $this   [OData-URL, section 5.1.1.14.6] . The current collection is also at the origin of the path $these , therefore s/Amount could be replaced by Amount in the following example. Sales?$apply=groupby((Product),filter($these/aggregate(s:s/Amount) lt 100)) $these can be prepended to collection path expressions like any , all and aggregate . (But we allow only $these/aggregate for now, so as not to touch the core spec.) See also ODATA-1456 . In a system query option (possibly nested within  $expand or $select ), when evaluating the boolCommonExpr in a filter or the commonExpr in an orderbyItem or  computeItem , the current collection is the collection being filtered or ordered or augmented. Products?$select=Sales($filter=$these/aggregate(s:Price with avg) gt $ this /Price) In an $apply  transformation, when evaluating the boolCommonExpr in a filterTrafo or the commonExpr in a computeExpr , the current collection is the input set of the transformation. When evaluating a commonExpr in its nearest collectionPathExpr , the current collection is the collection identified by the navigation path before the collectionPathExpr . This allows things like Products?$filter=Sales/any(p:p/Amount gt $these/aggregate(q:Amount)) See also oasis-tcs/odata-abnf#37 . The third paragraph in [OData-Aggr, section 3.24 "Function aggregate"] must be rewritten to reflect the rules above. The $these keyword and "current collection" concept introduced in these rules are not mentioned outside of that section for now. See  https://www.oasis-open.org/apps/org/workgroup/odata/download.php/69074/ODATA-1451.docx
    • Resolution:
      Show
      https://www.oasis-open.org/apps/org/workgroup/odata/download.php/69078/odata-data-aggregation-ext-v4.0-wd05.docx 2022-02-11: Resolution edited to allow the aggregate function in /$filter segments and orderby transformations: https://www.oasis-open.org/apps/org/workgroup/odata/download.php/69595/odata-data-aggregation-ext-v4.0-wd05.docx

      Description

      The current specification of the aggregate function (ODATA-1244) leaves undefined what the "input collection" is in cases like

      $filter=Sales/any(p:aggregate(p/Amount mul TaxRate with sum) gt 5) 
      

      that include property paths with and without lambda variable.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              heiko.theissen Heiko Theissen
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: