-
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
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.
{"report":{"apdex":0.5,"isInitial":true,"journeyId":"176b741e-be56-4950-8853-a7ef735cb339","key":"jira.project.issue.view-issue","navigationType":0,"readyForUser":1421.6000000014901,"redirectCount":0,"resourceLoadedEnd":1395,"resourceLoadedStart":340.69999999925494,"resourceTiming":[{"duration":730.4000000022352,"initiatorType":"link","name":"https://issues.oasis-open.org/s/3edeca31ab9ba77980aae0809fbe7121-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/0a4716d29b2d5b1bdcdb168b4efc119e/_/download/contextbatch/css/_super/batch.css","startTime":340.69999999925494,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":340.69999999925494,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1071.1000000014901,"responseStart":0,"secureConnectionStart":0},{"duration":730.5,"initiatorType":"link","name":"https://issues.oasis-open.org/s/7d2823769c2e7b66e860863fe879b7f8-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/9aebb1c0aaa4c36289529757ec9dbb54/_/download/contextbatch/css/project.issue.navigator,jira.view.issue,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&richediton=true","startTime":341,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":341,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1071.5,"responseStart":0,"secureConnectionStart":0},{"duration":730.4000000022352,"initiatorType":"link","name":"https://issues.oasis-open.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/8.0.5/_/download/batch/com.atlassian.auiplugin:split_aui.pattern.label/com.atlassian.auiplugin:split_aui.pattern.label.css","startTime":341.19999999925494,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":341.19999999925494,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1071.6000000014901,"responseStart":0,"secureConnectionStart":0},{"duration":730.3000000007451,"initiatorType":"link","name":"https://issues.oasis-open.org/s/645acc233eb869f48a571293b8358a7d-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/1.0/_/download/batch/jira.webresources:global-static-adgs/jira.webresources:global-static-adgs.css","startTime":341.3999999985099,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":341.3999999985099,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1071.699999999255,"responseStart":0,"secureConnectionStart":0},{"duration":730.1000000014901,"initiatorType":"link","name":"https://issues.oasis-open.org/s/a0dd6509771c1de0667aae5429c04cda-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/1.0/_/download/batch/jira.webresources:global-static/jira.webresources:global-static.css","startTime":341.69999999925494,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":341.69999999925494,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1071.800000000745,"responseStart":0,"secureConnectionStart":0},{"duration":739,"initiatorType":"script","name":"https://issues.oasis-open.org/s/e5479157e7a0c08b005e6522f2f04104-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/0a4716d29b2d5b1bdcdb168b4efc119e/_/download/contextbatch/js/_super/batch.js?locale=en-US","startTime":341.8999999985099,"connectEnd":341.8999999985099,"connectStart":341.8999999985099,"domainLookupEnd":341.8999999985099,"domainLookupStart":341.8999999985099,"fetchStart":341.8999999985099,"redirectEnd":0,"redirectStart":0,"requestStart":341.8999999985099,"responseEnd":1080.8999999985099,"responseStart":1080.8999999985099,"secureConnectionStart":341.8999999985099},{"duration":764.3999999985099,"initiatorType":"script","name":"https://issues.oasis-open.org/s/83514d5d4e8543747b02042eafcdc99c-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/9aebb1c0aaa4c36289529757ec9dbb54/_/download/contextbatch/js/project.issue.navigator,jira.view.issue,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en-US&richediton=true","startTime":342.5,"connectEnd":342.5,"connectStart":342.5,"domainLookupEnd":342.5,"domainLookupStart":342.5,"fetchStart":342.5,"redirectEnd":0,"redirectStart":0,"requestStart":342.5,"responseEnd":1106.8999999985099,"responseStart":1106.8999999985099,"secureConnectionStart":342.5},{"duration":766.9000000022352,"initiatorType":"script","name":"https://issues.oasis-open.org/s/70bb2263e59e7e1f04fbd137c80b895b-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/aae1242f5fc81cc6a5bb8bc963ccda29/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en-US","startTime":342.69999999925494,"connectEnd":342.69999999925494,"connectStart":342.69999999925494,"domainLookupEnd":342.69999999925494,"domainLookupStart":342.69999999925494,"fetchStart":342.69999999925494,"redirectEnd":0,"redirectStart":0,"requestStart":342.69999999925494,"responseEnd":1109.6000000014901,"responseStart":1109.6000000014901,"secureConnectionStart":342.69999999925494},{"duration":767.1000000014901,"initiatorType":"script","name":"https://issues.oasis-open.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":342.8999999985099,"connectEnd":342.8999999985099,"connectStart":342.8999999985099,"domainLookupEnd":342.8999999985099,"domainLookupStart":342.8999999985099,"fetchStart":342.8999999985099,"redirectEnd":0,"redirectStart":0,"requestStart":342.8999999985099,"responseEnd":1110,"responseStart":1110,"secureConnectionStart":342.8999999985099},{"duration":767.3999999985099,"initiatorType":"script","name":"https://issues.oasis-open.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":343,"connectEnd":343,"connectStart":343,"domainLookupEnd":343,"domainLookupStart":343,"fetchStart":343,"redirectEnd":0,"redirectStart":0,"requestStart":343,"responseEnd":1110.3999999985099,"responseStart":1110.3999999985099,"secureConnectionStart":343},{"duration":767.6000000014901,"initiatorType":"script","name":"https://issues.oasis-open.org/s/cda37faab827dbdf305de8efe8282062-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/8.0.5/_/download/batch/com.atlassian.auiplugin:split_aui.pattern.label/com.atlassian.auiplugin:split_aui.pattern.label.js?locale=en-US","startTime":343.19999999925494,"connectEnd":343.19999999925494,"connectStart":343.19999999925494,"domainLookupEnd":343.19999999925494,"domainLookupStart":343.19999999925494,"fetchStart":343.19999999925494,"redirectEnd":0,"redirectStart":0,"requestStart":343.19999999925494,"responseEnd":1110.800000000745,"responseStart":1110.800000000745,"secureConnectionStart":343.19999999925494},{"duration":768.6000000014901,"initiatorType":"link","name":"https://issues.oasis-open.org/s/07245784f53abc49bad9d9d4d36c577a-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/cadc4f20cc5c138dee060d42cf85f220/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":343.3999999985099,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":343.3999999985099,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1112,"responseStart":0,"secureConnectionStart":0},{"duration":768.3999999985099,"initiatorType":"script","name":"https://issues.oasis-open.org/rest/api/1.0/shortcuts/803004/a29179d70fa8562374ee16707692af77/shortcuts.js?context=issuenavigation&context=issueaction","startTime":343.5,"connectEnd":343.5,"connectStart":343.5,"domainLookupEnd":343.5,"domainLookupStart":343.5,"fetchStart":343.5,"redirectEnd":0,"redirectStart":0,"requestStart":343.5,"responseEnd":1111.8999999985099,"responseStart":1111.8999999985099,"secureConnectionStart":343.5},{"duration":706.5,"initiatorType":"link","name":"https://issues.oasis-open.org/s/f77fd89aa211a76b20e9b0e63564383c-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/4a9288299d147101bf66484f4be48925/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-jira.view.issue,-project.issue.navigator/batch.css?jira.create.linked.issue=true&richediton=true","startTime":406.8999999985099,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":406.8999999985099,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1113.3999999985099,"responseStart":0,"secureConnectionStart":0},{"duration":706.1999999992549,"initiatorType":"script","name":"https://issues.oasis-open.org/s/41525c48ddceeb9b11e54085268fc285-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/4a9288299d147101bf66484f4be48925/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-jira.view.issue,-project.issue.navigator/batch.js?jira.create.linked.issue=true&locale=en-US&richediton=true","startTime":407.19999999925494,"connectEnd":407.19999999925494,"connectStart":407.19999999925494,"domainLookupEnd":407.19999999925494,"domainLookupStart":407.19999999925494,"fetchStart":407.19999999925494,"redirectEnd":0,"redirectStart":0,"requestStart":407.19999999925494,"responseEnd":1113.3999999985099,"responseStart":1113.3999999985099,"secureConnectionStart":407.19999999925494},{"duration":959.8000000007451,"initiatorType":"script","name":"https://issues.oasis-open.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":417.30000000074506,"connectEnd":417.30000000074506,"connectStart":417.30000000074506,"domainLookupEnd":417.30000000074506,"domainLookupStart":417.30000000074506,"fetchStart":417.30000000074506,"redirectEnd":0,"redirectStart":0,"requestStart":417.30000000074506,"responseEnd":1377.1000000014901,"responseStart":1377.1000000014901,"secureConnectionStart":417.30000000074506},{"duration":952.3000000007451,"initiatorType":"script","name":"https://issues.oasis-open.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/nu8zej/803004/aeedb5937bed650f2f0cc4ec9ceaa5d3/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":442.69999999925494,"connectEnd":442.69999999925494,"connectStart":442.69999999925494,"domainLookupEnd":442.69999999925494,"domainLookupStart":442.69999999925494,"fetchStart":442.69999999925494,"redirectEnd":0,"redirectStart":0,"requestStart":442.69999999925494,"responseEnd":1395,"responseStart":1395,"secureConnectionStart":442.69999999925494},{"duration":91.40000000223517,"initiatorType":"xmlhttprequest","name":"https://issues.oasis-open.org/rest/webResources/1.0/resources","startTime":1280.8999999985099,"connectEnd":1280.8999999985099,"connectStart":1280.8999999985099,"domainLookupEnd":1280.8999999985099,"domainLookupStart":1280.8999999985099,"fetchStart":1280.8999999985099,"redirectEnd":0,"redirectStart":0,"requestStart":1280.8999999985099,"responseEnd":1372.300000000745,"responseStart":1372.300000000745,"secureConnectionStart":1280.8999999985099}],"threshold":1000,"fetchStart":0,"domainLookupStart":232,"domainLookupEnd":232,"connectStart":232,"connectEnd":282,"secureConnectionStart":257,"requestStart":282,"responseStart":330,"responseEnd":443,"domLoading":333,"domInteractive":1532,"domContentLoadedEventStart":1532,"domContentLoadedEventEnd":1578,"domComplete":1764,"loadEventStart":1764,"loadEventEnd":1768,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[],"measures":[],"correlationId":"f632d92dd2508e","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":134,"dbReadsTimeInMs":32,"dbConnsTimeInMs":37,"applicationHash":"4d4040e0714d65b7fffa4801569d014c0b16eaa9","experiments":[]}}
TC 2021-09-23: RESOLVED as proposed.