-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathodata-aggregation-abnf.txt
262 lines (220 loc) · 11.6 KB
/
odata-aggregation-abnf.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
;------------------------------------------------------------------------------
; OData Aggregation ABNF Construction Rules Version 4.0
;------------------------------------------------------------------------------
; 19 September 2023
;------------------------------------------------------------------------------
;
; Technical Committee:
; OASIS Open Data Protocol (OData) TC
; https://www.oasis-open.org/committees/odata
;
; Chairs:
; - Ralf Handl ([email protected]), SAP SE
; - Michael Pizzo ([email protected]), Microsoft
;
; Editors:
; - Ralf Handl ([email protected]), SAP SE
; - Hubert Heijkers ([email protected]), IBM
; - Gerald Krause ([email protected]), SAP SE
; - Michael Pizzo ([email protected]), Microsoft
; - Martin Zurmuehl ([email protected]), SAP SE
; - Heiko Theissen ([email protected]), SAP SE
;
; Additional artifacts:
; This grammar is one component of a Work Product which consists of:
; - OData Extension for Data Aggregation Version 4.0
; - OData Aggregation Vocabulary
; - OData Aggregation ABNF Construction Rules Version 4.0 (this document)
; - OData Aggregation ABNF Test Cases Version 4.0
;
; Related work:
; This specification is related to:
; - OData Version 4.01 Part 1: Protocol
; - OData Version 4.01 Part 2: URL Conventions
; - OData ABNF Construction Rules Version 4.01
; - OData ABNF Test Cases Version 4.01
; - OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01
; - OData Common Schema Definition Language (CSDL) XML Representation Version 4.01
; - OData JSON Format Version 4.01
; This specification replaces or supersedes:
; - None
;
; Declared XML namespaces:
; - None
;
; Abstract:
; This specification adds basic grouping and aggregation functionality (such as
; sum, min, and max) to the Open Data Protocol (OData) without changing any
; of the base principles of OData.
;
; Overview:
; This grammar uses the ABNF defined in RFC5234 and RFC7405.
;
; It extends the OData ABNF Construction Rules Version 4.01
;
; Contents:
; 1. New alternatives for OData ABNF Construction Rules
; 2. System Query Option $apply
; 3. Extensions to $filter
;
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; 1. New alternatives for OData ABNF Construction Rules
;------------------------------------------------------------------------------
systemQueryOption =/ apply
expandOption =/ apply
boolMethodCallExpr =/ isdefinedExpr
primitiveProperty =/ customAggregate
firstMemberExpr =/ currCollectionExpr
collectionPathExpr =/ %s"/aggregate" OPEN BWS aggregateFunctionExpr BWS CLOSE
;------------------------------------------------------------------------------
; 2. System Query Option $apply
;------------------------------------------------------------------------------
apply = ( "$apply" / "apply" ) EQ applyExpr
applyExpr = applyTrafo *( "/" applyTrafo )
applyTrafo = aggregateTrafo
/ computeTrafo
/ concatTrafo
/ groupbyTrafo
/ joinTrafo
/ nestTrafo
/ outerjoinTrafo
/ preservingTrafo
preservingTrafo = bottomcountTrafo
/ bottompercentTrafo
/ bottomsumTrafo
/ filterTrafo
/ identityTrafo
/ orderbyTrafo
/ searchTrafo
/ skipTrafo
/ topTrafo
/ topcountTrafo
/ toppercentTrafo
/ topsumTrafo
/ ancestorsTrafo
/ descendantsTrafo
/ traverseTrafo
/ customFunction ; custom functions could be preserving, hence are allowed in preservingTrafos
preservingTrafos = preservingTrafo *( "/" preservingTrafo )
aggregateTrafo = %s"aggregate" OPEN BWS aggregateExpr *( BWS COMMA BWS aggregateExpr ) BWS CLOSE
aggregateExpr = ( aggrPathPrefix / aggrCastPath ) nonprimAggWith [ aggregateFrom ] asAlias
/ aggregatableExpW [ aggregateFrom ] asAlias
/ aggregateCount [ aggregateFrom ] asAlias
/ aggregateCustom [ [ customFrom ] asAlias ]
aggregatableExpr = commonExpr ; resulting in an aggregatable value
aggregatableExpW = aggregatableExpr aggregateWith
/ [ aggrCastPath "/" ] aggrPrimPath aggregateWith
aggrPathPrefix = [ aggrCastPath "/" ] aggrPropPath
aggregateWith = RWS %s"with" RWS aggregateMethod
nonprimAggWith = RWS %s"with" RWS nonprimAggMethod
aggregateFrom = RWS %s"from" RWS groupingProperties aggregateWith [ aggregateFrom ]
customFrom = RWS %s"from" RWS groupingProperties [ aggregateWith ] [ customFrom ]
aggregateMethod = %s"sum"
/ %s"min"
/ %s"max"
/ %s"average"
/ nonprimAggMethod
nonprimAggMethod = %s"countdistinct"
/ namespace "." odataIdentifier ; custom aggregation methods may work on non-primitive values
aggregateCount = %s"$count"
/ [ aggrCastPath "/" ] aggrPrimPath count
/ ( aggrPathPrefix / aggrCastPath ) count
aggregateCustom = [ ( aggrPathPrefix / aggrCastPath ) "/" ] customAggregate
asAlias = RWS %s"as" RWS expressionAlias
expressionAlias = odataIdentifier
customAggregate = odataIdentifier
; Three flavors of data aggregation paths are defined now:
; - one for use in aggregate, whose segments can be single- or collection-valued (rules with prefix aggr)
; - one for use in groupby, whose segments must be single-valued (rules with prefix sngl)
; - one for use in addnested, without entity-valued segments (rule with prefix nest)
; Term casts are not allowed in data aggregation paths.
aggrPropStep = ( complexProperty / complexColProperty / entityNavigationProperty / entityColNavigationProperty )
[ "/" aggrCastPath ]
aggrPropPath = aggrPropStep [ "/" aggrPropPath ]
aggrPrimPath = aggrPropStep "/" aggrPrimPath
/ primitiveProperty / primitiveColProperty / streamProperty
aggrCastPath = optionallyQualifiedComplexTypeName / optionallyQualifiedEntityTypeName
nestPropPath = ( complexProperty / complexColProperty ) [ [ "/" optionallyQualifiedComplexTypeName ] "/" nestPropPath ]
snglPropPath = ( complexProperty / entityNavigationProperty ) [ [ "/" aggrCastPath ] "/" snglPropPath ]
snglPrimPath = ( complexProperty / entityNavigationProperty ) [ "/" aggrCastPath ] "/" snglPrimPath
/ primitiveProperty / streamProperty
groupingProperty = [ aggrCastPath "/" ] ( snglPrimPath / snglPropPath )
groupingProperties = groupingProperty *( BWS COMMA BWS groupingProperty )
; Expressions evaluable on a collection
collectionExpr = commonExpr ; but where every firstMemberExpr must be a currCollectionExpr
currCollectionExpr = %s"$these" collectionPathExpr
computeTrafo = %s"compute" OPEN BWS computeExpr *( BWS COMMA BWS computeExpr ) BWS CLOSE
computeExpr = commonExpr asAlias
bottomcountTrafo = %s"bottomcount" OPEN BWS collectionExpr BWS COMMA BWS commonExpr BWS CLOSE
bottompercentTrafo = %s"bottompercent" OPEN BWS collectionExpr BWS COMMA BWS commonExpr BWS CLOSE
bottomsumTrafo = %s"bottomsum" OPEN BWS collectionExpr BWS COMMA BWS commonExpr BWS CLOSE
concatTrafo = %s"concat" OPEN BWS applyExpr 1*( BWS COMMA BWS applyExpr ) BWS CLOSE
nestTrafo = %s"nest" OPEN BWS nestApplyExpr BWS CLOSE
/ %s"addnested" OPEN BWS nestPath BWS COMMA BWS nestApplyExpr BWS CLOSE
nestPath = [ aggrCastPath "/" ]
( [ nestPropPath "/" ] navigationProperty [ "/" optionallyQualifiedEntityTypeName ]
/ nestPropPath
)
nestApplyExpr = applyExpr asAlias *( BWS COMMA BWS applyExpr asAlias )
joinTrafo = %s"join" OPEN BWS joinProperty asAlias [ BWS COMMA BWS applyExpr ] BWS CLOSE
outerjoinTrafo = %s"outerjoin" OPEN BWS joinProperty asAlias [ BWS COMMA BWS applyExpr ] BWS CLOSE
joinProperty = ( complexColProperty
/ complexAnnotationInQuery ; must be collection-valued
/ entityColNavigationProperty [ "/" optionallyQualifiedEntityTypeName ]
/ entityAnnotationInQuery ; must be collection-valued
)
ancestorsTrafo = %s"ancestors" OPEN BWS
recHierReference BWS
COMMA BWS preservingTrafos BWS
[ COMMA BWS 1*DIGIT BWS ]
[ COMMA BWS %s"keep start" BWS ]
CLOSE
descendantsTrafo = %s"descendants" OPEN BWS
recHierReference BWS
COMMA BWS preservingTrafos BWS
[ COMMA BWS 1*DIGIT BWS ]
[ COMMA BWS %s"keep start" BWS ]
CLOSE
traverseTrafo = %s"traverse" OPEN BWS
recHierReference BWS
COMMA BWS ( %s"preorder" / %s"postorder" ) BWS
[ COMMA BWS preservingTrafos BWS ]
[ COMMA BWS orderbyItem *( BWS COMMA BWS orderbyItem ) BWS ]
CLOSE
recHierReference = rootExpr ; must have type Collection(Edm.EntityType)
BWS COMMA BWS recHierQualifier
BWS COMMA BWS recHierPropertyPath
recHierQualifier = odataIdentifier
recHierPropertyPath = [ aggrCastPath "/" ] aggrPrimPath
filterTrafo = %s"filter" OPEN BWS boolCommonExpr BWS CLOSE
searchTrafo = %s"search" OPEN BWS ( searchExpr / searchExpr-incomplete ) BWS CLOSE
groupbyTrafo = %s"groupby" OPEN BWS groupbyList [ BWS COMMA BWS applyExpr ] BWS CLOSE
groupbyList = OPEN BWS groupbyElement *( BWS COMMA BWS groupbyElement ) BWS CLOSE
groupbyElement = groupingProperty / rollupLevels / rollupRecursive
rollupLevels = %s"rollup" OPEN BWS ( rollupUnnamedHier / rollupNamedHier ) BWS CLOSE
rollupRecursive = %s"rolluprecursive" OPEN BWS
recHierReference BWS
[ COMMA BWS preservingTrafos BWS ]
CLOSE
rollupUnnamedHier = groupingProperty 1*( BWS COMMA BWS groupingProperty )
rollupNamedHier = odataIdentifier ; qualifier of Aggregation.LeveledHierarchy annotation
identityTrafo = %s"identity"
topcountTrafo = %s"topcount" OPEN BWS collectionExpr BWS COMMA BWS commonExpr BWS CLOSE
toppercentTrafo = %s"toppercent" OPEN BWS collectionExpr BWS COMMA BWS commonExpr BWS CLOSE
topsumTrafo = %s"topsum" OPEN BWS collectionExpr BWS COMMA BWS commonExpr BWS CLOSE
topTrafo = %s"top" OPEN BWS 1*DIGIT BWS CLOSE
skipTrafo = %s"skip" OPEN BWS 1*DIGIT BWS CLOSE
orderbyTrafo = %s"orderby" OPEN orderbyItem *( BWS COMMA BWS orderbyItem ) CLOSE
customFunction = namespace "." ( entityColFunction / complexColFunction / primitiveColFunction ) functionExprParameters
;------------------------------------------------------------------------------
; 3. New functions
;------------------------------------------------------------------------------
isdefinedExpr = %s"isdefined" OPEN BWS ( firstMemberExpr ) BWS CLOSE
aggregateFunctionExpr = aggregatableExpW [ aggregateFrom ]
/ aggrPathPrefix nonprimAggWith [ aggregateFrom ]
/ aggregateCount [ aggregateFrom ]
/ aggregateCustom [ customFrom ]
;------------------------------------------------------------------------------
; End of odata-aggregation-abnf
;------------------------------------------------------------------------------