Skip to content
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

MultiLevelExpand transformation #293

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4750db8
auto-expand transformation
HeikoTheissen Nov 10, 2023
53368e3
Avoid EnumType
HeikoTheissen Nov 10, 2023
64e5ae7
Instance annotations for auto-expanded result sets
HeikoTheissen Nov 14, 2023
b5a6f34
Reprased definitions
HeikoTheissen Nov 14, 2023
9238702
SortOrder -> SortOrderType
HeikoTheissen Nov 14, 2023
34b5a64
Avoid <dt>
HeikoTheissen Nov 14, 2023
443f99c
After alignment with @uhlmannm
HeikoTheissen Nov 15, 2023
2fb8ff2
rephrasing
HeikoTheissen Nov 15, 2023
f5dea9f
Make `LeafLevel` mandatory
HeikoTheissen Nov 15, 2023
41b289a
Don't call out instance annotation
HeikoTheissen Feb 2, 2024
2df14e4
Merge remote-tracking branch 'origin/main' into auto-expand
HeikoTheissen Apr 4, 2024
defafdf
Allowed values for DrillState
HeikoTheissen Apr 8, 2024
8584dfe
Merge remote-tracking branch 'origin/main' into auto-expand
HeikoTheissen Apr 11, 2024
f27abe8
auto-refreshed
HeikoTheissen Apr 11, 2024
3ca799d
@uhlmannm's suggestion
HeikoTheissen Apr 12, 2024
92f1abd
Simplifications agreed in V4 table meeting
HeikoTheissen Apr 26, 2024
bb78f7d
Example request
HeikoTheissen Apr 26, 2024
4181573
Rephrased
HeikoTheissen Apr 26, 2024
b227e7f
Typos
HeikoTheissen Apr 26, 2024
e390b0c
@uhlmannm's comments
HeikoTheissen Apr 29, 2024
b9ecf4f
explained example
HeikoTheissen Apr 29, 2024
b587137
expand N levels
HeikoTheissen Apr 29, 2024
ae774a6
renamed type
HeikoTheissen Apr 29, 2024
3cb5082
typo
HeikoTheissen Apr 29, 2024
c9bbadf
more links
HeikoTheissen Apr 29, 2024
3e6379a
corrected LeavesCount, ResultEntriesCount
HeikoTheissen Apr 29, 2024
f98c999
example formatting
HeikoTheissen Apr 29, 2024
64f96eb
save lines
HeikoTheissen Apr 29, 2024
bc35559
round parentheses for in
HeikoTheissen Apr 29, 2024
9f24039
More elegance
HeikoTheissen Apr 29, 2024
8c7b80b
reword: deeper -> finer-grained
HeikoTheissen Apr 29, 2024
4dfd1c6
Sort order like Common.SortOrderType
HeikoTheissen May 2, 2024
5036eba
As agreed in meeting on 2024-05-24
HeikoTheissen May 24, 2024
192cc17
Explain D vs. A
HeikoTheissen May 24, 2024
fbe94b9
Merge remote-tracking branch 'origin/main' into auto-expand
HeikoTheissen Jul 12, 2024
f603089
Merge remote-tracking branch 'origin/main' into auto-expand
HeikoTheissen Jan 10, 2025
66e2af7
subtotals at bottom
HeikoTheissen Jan 10, 2025
4cd0ad4
@uhlmannm's suggestion (slightly reworked)
HeikoTheissen Jan 10, 2025
f7059d6
AutoExpand -> MultiLevelExpand
HeikoTheissen Jan 14, 2025
e51acaa
@ralfhandl's suggestion (slightly adapted)
HeikoTheissen Jan 15, 2025
ff2ea96
@ThomasChadzelek's comments
HeikoTheissen Feb 11, 2025
8b99b2c
Explain the cast
HeikoTheissen Feb 11, 2025
00badf5
Merge remote-tracking branch 'origin/main' into auto-expand
HeikoTheissen Feb 21, 2025
0ae8299
@agoerler's suggestion
HeikoTheissen Feb 21, 2025
20ee029
You can never be explicit enough
HeikoTheissen Feb 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions vocabularies/Analytics.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -161,6 +164,115 @@
"@[email protected]": "Adding a list of other terms that can be annotated to it.",
"@Validation.ApplicableTerms": ["Common.Label"]
}
},
"MultiLevelExpand": [
{
"$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:\nfilter on columns `Industry`, `Amount` and `Currency`,\norder by `Amount` descending,\nshow 2 levels, with two exceptions\n```\n$apply=filter(Industry in ('IT','AI'))\n/groupby((Country,Region,Segment,Industry),\n filter($these/aggregate(Amount) gt 0 and\n $these/aggregate(Currency) ne null))\n/concat(\n groupby((Country,Region,Segment,Industry))\n /aggregate($count as LeavesCount),\n aggregate(Amount,Currency),\n Analytics.MultiLevelExpand(\n Levels=[{\"DimensionProperties\":[\"Country\"],\"AdditionalProperties\":[\"CountryName\"]},\n {\"DimensionProperties\":[\"Region\"],\"AdditionalProperties\":[\"RegionName\"]},\n {\"DimensionProperties\":[\"Segment\",\"Industry\"],\"AdditionalProperties\":[]}],\n Aggregation=[\"Amount\",\"Currency\"],\n SiblingOrder=[{\"Property\":\"Amount\",\"Descending\":true}],\n ShowLevels=2,\n ExpandEntries=[{\"Entry\":[\"US\"],\"Levels\":0},\n {\"Entry\":[\"DE\",\"BW\"],\"Levels\":1}]\n )/concat(aggregate($count as ResultEntriesCount),\n skip(20)/top(10)))\n```\n",
"$Parameter": [
{
"$Name": "InputSet",
"$Collection": true,
"$Type": "Edm.EntityType",
"@Core.Description": "Entity set to be processed"
},
{
"$Name": "Levels",
"$Collection": true,
"$Type": "Analytics.MultiLevelExpandLevel",
"@Core.Description": "Collection of aggregation levels forming a leveled hierarchy",
"@Core.LongDescription": "Each element in the collection defines the properties that constitute one level.\n A property must not be 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 is the leveled hierarchy with these levels in preorder,\n entries on the finest-grained level cannot be expanded further.\n All referenced properties must be groupable."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

referenced properties must be groupable

should we use the term "dimension" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because CountryName is groupable and can appear here, but is not a dimension. It is a dimension text, there are also dimension attributes.

},
{
"$Name": "Aggregation",
"$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.MultiLevelExpandSiblingOrder",
"@Core.Description": "Sort specification to apply to all direct descendants of a given entry in the resulting leveled hierarchy"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Sibling" vs "all direct descendants of a given entry"

maybe we could harmonize the wording

},
{
"$Name": "ShowLevels",
"$Type": "Edm.Int64",
"@Core.Description": "Number N of levels to be shown in the initial expansion",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we start counting with 0 or with 1? 1, I assume.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing to be shown at level 0. ShowLevels = 0 gives an empty result.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But is this clear enough from the description(s)?

"@Core.LongDescription": "The initial expansion shows the first N levels as defined in `Levels` (0 ≤ N ≤ length of `Levels`).\n If this parameter is omitted, all levels are shown.",
"@Core.OptionalParameter": {}
},
{
"$Name": "ExpandEntries",
"$Collection": true,
"$Type": "Analytics.MultiLevelExpandEntry",
"@Core.Description": "Entries with exceptional expansion",
"@Core.OptionalParameter": {}
},
{
"$Name": "SubtotalsAtBottom",
"$Type": "Edm.Bool",
"@Core.Description": "Whether to duplicate the group headers so that they appear before and after their descendants",
Comment on lines +217 to +219

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"AtBottom" vs "before and after"

Copy link
Contributor Author

@HeikoTheissen HeikoTheissen Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name reflects what you see in the UI. The description makes clear that the row appears duplicated in the result set.

"@Core.LongDescription": "The entry before has [DrillState](Hierarchy.md#HierarchyType) `expanded`,\n the entry after has DrillState `subtotal`.",
"@Core.OptionalParameter": { "DefaultValue": "false" }
}
],
"$ReturnType": {
"$Collection": true,
"$Type": "Edm.EntityType",
"@Core.Description": "Output set including the instance annotation [`LevelInformation`](#LevelInformation)"
}
}
],
"MultiLevelExpandLevel": {
"$Kind": "ComplexType",
"@Common.Experimental": true,
"@Core.Description": "Property names constituting a level in an [unnamed leveled hierarchy](#MultiLevelExpand)",
"@Core.LongDescription": "`DimensionProperties` must be used to identify entries in [`ExpandEntries/Entry`](#MultiLevelExpandEntry),\n otherwise they have the same effect as `AdditionalProperties`.",
"DimensionProperties": {
"$Collection": true,
"@Core.Description": "A non-empty list of property names that define a combination of dimension values"
},
"AdditionalProperties": {
"$Collection": true,
"@Core.Description": "A possibly empty list of names of additional properties of the dimensions that occur in `DimensionProperties`"
}
},
"MultiLevelExpandSiblingOrder": {
"$Kind": "ComplexType",
"@Common.Experimental": true,
"@Core.Description": "Sibling order in an [unnamed leveled hierarchy](#MultiLevelExpand)",
"Property": { "@Core.Description": "Property by which to sort" },
"Descending": {
"$Type": "Edm.Boolean",
"$Nullable": true,
"@Core.Description": "Sort direction, ascending if not specified otherwise"
}
},
"MultiLevelExpandEntry": {
"$Kind": "ComplexType",
"@Common.Experimental": true,
"@Core.Description": "Expansion state of an entry in an [unnamed leveled hierarchy](#MultiLevelExpand)",
"Entry": {
"$Collection": true,
"@Core.Description": "An entry on a given [level](#MultiLevelExpandLevel) is identified by a list of values for the `DimensionProperties` that constitute all levels up to and including the given one"
},
"Levels": {
"$Type": "Edm.Int64",
"$Nullable": true,
"@Core.Description": "Number of levels to be expanded, null means all levels, 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 [`MultiLevelExpand`](#MultiLevelExpand) transformation"
}
}
}
Loading