Skip to content
Merged
Changes from 1 commit
Commits
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
48 changes: 25 additions & 23 deletions advanced/odata.md
Original file line number Diff line number Diff line change
Expand Up @@ -1052,21 +1052,22 @@ If the `groupby` transformation only includes a subset of the entity keys, the r

### Transformations

| Transformation | Description | Node.js | Java |
|------------------------------|---------------------------------------------|:------------------:|:-----:|
| `filter` | filter by filter expression | <X/> | <X/> |
| `search` | filter by search term or expression | <Na/> | <X/> |
| `groupby` | group by dimensions and aggregates values | <X/> | <X/> |
| `aggregate` | aggregate values | <X/> | <X/> |
| `compute` | add computed properties to the result set | <Na/> | <X/> |
| `expand` | expand navigation properties | <Na/> | <Na/> |
| `concat` | append additional aggregation to the result | <X/> | <X/> |
| `skip` / `top` | paginate | <X/> | <X/> |
| `orderby` | sort the input set | <X/> | <X/> |
| `topcount`/`bottomcount` | retain highest/lowest _n_ values | <Na/> | <Na/> |
| `toppercent`/`bottompercent` | retain highest/lowest _p_% values | <Na/> | <Na/> |
| `topsum`/`bottomsum` | retain _n_ values limited by sum | <Na/> | <Na/> |

| Transformation | Description | Node.js | Java |
|------------------------------|----------------------------------------------|:------------------:|:-----:|
| `filter` | filter by filter expression | <X/> | <X/> |
| `search` | filter by search term or expression | <Na/> | <X/> |
| `groupby` | group by dimensions and aggregates values | <X/> | <X/> |
| `aggregate` | aggregate values | <X/> | <X/> |
| `compute` | add computed properties to the result set | <Na/> | <X/> |
| `expand` | expand navigation properties | <Na/> | <Na/> |
| `concat` | append additional aggregation to the result | <X/> | <X/> |
| `skip` / `top` | paginate | <X/> | <X/> |
| `orderby` | sort the input set | <X/> | <X/> |
| `topcount`/`bottomcount` | retain highest/lowest _n_ values | <Na/> | <Na/> |
| `toppercent`/`bottompercent` | retain highest/lowest _p_% values | <Na/> | <Na/> |
| `topsum`/`bottomsum` | retain _n_ values limited by sum | <Na/> | <Na/> |
| `TopLevels` | retain only _n_ levels of a hierarchy | <X/> | <X/> |
| `ancestors/descendants` | retain ancestors/descendants of specific nodes | <X/> | <X/> |

#### `concat`

Expand Down Expand Up @@ -1105,17 +1106,15 @@ Provide support for hierarchy attribute calculation and navigation, and allow th

| Transformation | Description | Node.js | Java |
|-----------------------------------------------|------------------------------------------------------------------|:-------:|:------------------:|
| `com.sap.vocabularies.Hierarchy.v1.TopLevels` | generate a hierarchy based on recursive parent-child source data | <X/><sup>(1)</sup> | <X/><sup>(1)</sup> |
| `ancestors` | return all ancestors of a set of start nodes in a hierarchy | <X/><sup>(1)</sup> | <X/><sup>(1)</sup> |
| `descendants` | return all descendants of a set of start nodes in a hierarchy | <X/><sup>(1)</sup> | <X/><sup>(1)</sup> |

- <sup>(1)</sup> Beta feature, API may change
| `com.sap.vocabularies.Hierarchy.v1.TopLevels` | generate a hierarchy based on recursive parent-child source data | <X/><sup>(1)</sup> | <X/> |
| `ancestors` | return all ancestors of a set of start nodes in a hierarchy | <X/><sup>(1)</sup> | <X/> |
| `descendants` | return all descendants of a set of start nodes in a hierarchy | <X/><sup>(1)</sup> | <X/> |

Generic implementation is supported on the following databases:

| | SAP HANA | H2 | PostgreSQL | SQLite |
|---|---|---|---|---|
| CAP Java | ✓ | ✓ | | |
| CAP Java | ✓ | ✓ | | |
| CAP Node.js | ✓ | |✓ |✓ |

:::info
Expand Down Expand Up @@ -1152,8 +1151,11 @@ GET SalesOrganizations?$apply=
| `average` | average of values | <X/> | <X/> |
| `countdistinct` | count of distinct values | <X/> | <X/> |
| custom method | custom aggregation method | <Na/> | <Na/> |
| custom aggregate | predefined custom aggregate<sup>1</sup> | <X/> | <X/> |
| `$count` | number of instances in input set | <X/> | <X/> |

<sup>1</sup> CAP Node.js does not support custom aggregates for currencies or units of measure.

### Custom Aggregates

Instead of explicitly using an expression with an aggregation method in the `aggregate` transformation, the client can use a _custom aggregate_. A custom aggregate can be considered as a virtual property that aggregates the input set. It's calculated on the server side. The client doesn't know _How_ the custom aggregate is calculated.
Expand Down Expand Up @@ -1188,7 +1190,7 @@ which is equivalent to:
GET /Books?$apply=aggregate(stock with sum as stock) HTTP/1.1
```

#### Currencies and Units of Measure
#### Currencies and Units of Measure {.java}

If a property represents a monetary amount, it may have a related property that indicates the amount's *currency code*. Analogously, a property representing a measured quantity can be related to a *unit of measure*. To indicate that a property is a currency code or a unit of measure it can be annotated with the [Semantics Annotations](https://help.sap.com/docs/SAP_NETWEAVER_750/cc0c305d2fab47bd808adcad3ca7ee9d/fbcd3a59a94148f6adad80b9c97304ff.html) `@Semantics.currencyCode` or `@Semantics.unitOfMeasure`.
The aggregation method (typically, sum) is specified with the `@Aggregation.default` annotation.
Expand Down Expand Up @@ -1222,7 +1224,7 @@ A custom aggregate for a currency code or unit of measure should also be exposed
| chain transformations | <X/> | <X/> |
| chain transformations within group by | <Na/> | <Na/> |
| `groupby` with `rollup`/`$all` | <Na/> | <Na/> |
| `$expand` result set of `$apply` | <Na/> | <Na/> |
| `$expand` result set of `$apply` | <Na/> | <X/> |
| `$filter`/`$search` result set | <X/> | <X/> |
| sort result set with `$orderby` | <X/> | <X/> |
| paginate result set with `$top`/`$skip` | <X/> | <X/> |
Expand Down