-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-expand transformation #293
base: main
Are you sure you want to change the base?
Changes from 19 commits
4750db8
53368e3
64e5ae7
b5a6f34
9238702
34b5a64
443f99c
2fb8ff2
f5dea9f
41b289a
2df14e4
defafdf
8584dfe
f27abe8
3ca799d
92f1abd
bb78f7d
4181573
b227e7f
e390b0c
b9ecf4f
b587137
ae774a6
3cb5082
c9bbadf
3e6379a
f98c999
64f96eb
bc35559
9f24039
8c7b80b
4dfd1c6
5036eba
192cc17
fbe94b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -12,6 +12,9 @@ | |||
}, | ||||
"https://sap.github.io/odata-vocabularies/vocabularies/Common.json": { | ||||
"$Include": [{ "$Namespace": "com.sap.vocabularies.Common.v1", "$Alias": "Common" }] | ||||
}, | ||||
"https://sap.github.io/odata-vocabularies/vocabularies/Hierarchy.json": { | ||||
"$Include": [{ "$Namespace": "com.sap.vocabularies.Hierarchy.v1", "$Alias": "Hierarchy" }] | ||||
} | ||||
}, | ||||
"com.sap.vocabularies.Analytics.v1": { | ||||
|
@@ -161,6 +164,102 @@ | |||
"@[email protected]": "Adding a list of other terms that can be annotated to it.", | ||||
"@Validation.ApplicableTerms": ["Common.Label"] | ||||
} | ||||
}, | ||||
"AutoExpand": [ | ||||
{ | ||||
"$Kind": "Function", | ||||
"$EntitySetPath": "InputSet", | ||||
"$IsBound": true, | ||||
"@Common.Experimental": true, | ||||
"@Core.Description": "`$apply` transformation that expands an unnamed leveled hierarchy with custom aggregation of certain properties", | ||||
"@Core.LongDescription": "Example transformation sequence:\n```\n$apply=filter(Industry eq 'IT')\n/groupby((Country,CountryName,Region,RegionName),\n filter($these/aggregate(Amount) gt 0 and\n $these/aggregate(Currency) ne null))\n/concat(\n Analytics.AutoExpand(\n Levels=[{\"P\":[\"Country\",\"CountryName\"]},\n {\"P\":[\"Region\",\"RegionName\"]}],\n LeafLevel=[\"Segment\",\"Industry\"],\n Aggregation=[\"Amount\",\"Currency\"],\n SiblingOrder=[{\"Property\":\"Amount\",\n \"Order\":\"desc\"}],\n ExpandLevels=[{\"Entry\":[\"US\",\"USA\"],\"Levels\":0},\n {\"Entry\":[\"DE\",\"Germany\",\"BW\",\"Baden-Württemberg\"],\"Levels\":2}])\n /concat(aggregate($count) as ResultEntriesCount,\n skip(20)/top(10)),\n aggregate(Amount,Currency))\n```\n", | ||||
"$Parameter": [ | ||||
{ | ||||
"$Name": "InputSet", | ||||
"$Collection": true, | ||||
"$Type": "Edm.EntityType", | ||||
"@Core.Description": "Entity set to be processed" | ||||
}, | ||||
{ | ||||
"$Name": "Levels", | ||||
"$Collection": true, | ||||
"$Type": "Analytics.AutoExpandLevel", | ||||
"@Core.Description": "Collection of aggregation levels forming the visible part of a leveled hierarchy", | ||||
"@Core.LongDescription": "Each element in the collection defines the properties that constitute one level.\n A property must not referenced by more than one level.\n The first element in the collection defines the property names of the coarsest level,\n the following elements define the property names of consecutively finer-grained aggregation levels.\n The function result comprises the leveled hierarchy with these levels in preorder.\n All referenced properties must be groupable." | ||||
}, | ||||
{ | ||||
"$Name": "LeafLevel", | ||||
"$Collection": true, | ||||
"@Core.Description": "A possibly empty set of property names that constitute, together with the property names from `Levels`, the leaf level of the leveled hierarchy", | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I wonder how that would work. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There can be several properties used for grouping on the leaf level that are not used for visual grouping / group headers.
I think we had decided somewhen in the past that 3. is not necessary for the AutoExpand function as one can simply as collapsed visual groups to 2. But I wonder whether that decision is still good when introducing ExpandLevels. Should the backend then not know which visual groups are introduced, how grouping is done on leaf level and how deep to expand initially? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The leaf level is just the deepest grouping level, therefore we only need the parameter In the current definition, nodes not mentioned in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we can do it like that. But the question is how to denote the leaf level. Is it always the last of the Levels? And hence this last level is not and cannot be expanded? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it be stated explicitly in the Levels description? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you look at the FE examples, then on the leaf level there are individual (unaggregated) records. If that is the target state, one could also argue that the last level can still be expanded and below this last level are the unaggregated records. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added odata-vocabularies/vocabularies/Analytics.xml Line 224 in 8c7b80b
|
||||
"@Core.LongDescription": "Property names that occur in `Levels` must not be repeated here.\n All referenced properties must be groupable." | ||||
}, | ||||
{ | ||||
"$Name": "Aggregation", | ||||
HeikoTheissen marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
"$Collection": true, | ||||
"@Core.Description": "Properties to aggregate for all result entries on all levels", | ||||
"@Core.LongDescription": "All properties in this collection must be custom aggregates." | ||||
}, | ||||
{ | ||||
"$Name": "SiblingOrder", | ||||
"$Collection": true, | ||||
"$Type": "Analytics.AutoExpandSiblingOrder", | ||||
"@Core.Description": "Sort specification to apply to all direct descendants of a given entry in the resulting leveled hierarchy" | ||||
}, | ||||
{ | ||||
"$Name": "ExpandLevels", | ||||
"$Collection": true, | ||||
"$Type": "Analytics.AutoExpandLevelType", | ||||
"@Core.Description": "Entries to be specially (not fully) expanded", | ||||
"@Core.OptionalParameter": {} | ||||
} | ||||
], | ||||
"$ReturnType": { | ||||
"$Collection": true, | ||||
"$Type": "Edm.EntityType", | ||||
"@Core.Description": "Output set including the instance annotation [`LevelInformation`](#LevelInformation)" | ||||
} | ||||
} | ||||
], | ||||
"AutoExpandLevel": { | ||||
"$Kind": "ComplexType", | ||||
"@Common.Experimental": true, | ||||
"P": { "$Collection": true, "@Core.Description": "A non-empty set of property names constituting a level" } | ||||
HeikoTheissen marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
}, | ||||
"AutoExpandSiblingOrder": { | ||||
"$Kind": "ComplexType", | ||||
"@Common.Experimental": true, | ||||
"Property": { "@Core.Description": "Property by which to sort" }, | ||||
"Order": { | ||||
"$Type": "Analytics.SortOrderType", | ||||
"$DefaultValue": "Analytics.SortOrderType/Asc", | ||||
"@Core.Description": "Sorting direction" | ||||
} | ||||
}, | ||||
"SortOrderType": { | ||||
"$Kind": "TypeDefinition", | ||||
"$UnderlyingType": "Edm.String", | ||||
"@Common.Experimental": true, | ||||
"@Validation.AllowedValues": [ | ||||
{ "Value": "asc", "@Core.Description": "Sort in ascending order" }, | ||||
{ "Value": "desc", "@Core.Description": "Sort in descending order" } | ||||
] | ||||
}, | ||||
"AutoExpandLevelType": { | ||||
"$Kind": "ComplexType", | ||||
"@Common.Experimental": true, | ||||
"@Core.Description": "Information about entries in a leveled hierarchy that are not completely expanded", | ||||
"Entry": { | ||||
"$Collection": true, | ||||
"@Core.Description": "An entry on a given [level](#AutoExpandLevel) is identified by a collection of values for the properties that constitute all levels up to the given one" | ||||
}, | ||||
"Levels": { "$Type": "Edm.Int64", "@Core.Description": "Number of levels to be expanded, 0 means collapsed" } | ||||
}, | ||||
"LevelInformation": { | ||||
"$Kind": "Term", | ||||
"$Type": "Hierarchy.HierarchyType", | ||||
"$AppliesTo": ["EntityType"], | ||||
"@Common.Experimental": true, | ||||
"@Core.Description": "Information about grouping levels in the result set of a request including the [`AutoExpand`](#AutoExpand) transformation" | ||||
} | ||||
} | ||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In UI5 we start with the leaves count that is missing in the example. It would be a term
groupby((Country,CountryName,Region,RegionName))/aggregate($count as LeavesCount)
in the outer concat followed by the grand total termaggregate(Amount,Currency)
that is currently last in the example. The third term in the outer concat would beAnalytics.AutoExpand(...)/concat(aggregate($count) as ResultEntriesCount,skip(20)/top(10))
.