From d1216a9df82d64e8570c6affbdf4bd93bef8b5f8 Mon Sep 17 00:00:00 2001 From: Lars Lutz <56645452+larslutz96@users.noreply.github.com> Date: Wed, 28 Feb 2024 11:36:28 +0100 Subject: [PATCH 1/3] Update cds-ql.md Add warning: When using the combination of $apply with groupby and only a subset of keys is included, it can lead to the result not being uniquely sorted anymore. --- node.js/cds-ql.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node.js/cds-ql.md b/node.js/cds-ql.md index 57bb79231..6bf4bbc04 100644 --- a/node.js/cds-ql.md +++ b/node.js/cds-ql.md @@ -511,6 +511,9 @@ SELECT ... .orderBy ('a.name', 'b desc') SELECT ... .orderBy ({ref:['a','name']}, {ref:['b'],sort:'desc'}) ``` +::: warning +When using $apply with groupby and only a subset of keys is included, it can lead to the result not being uniquely sorted anymore. +::: ### .limit() {.method} From c73a20a28f709dc0645e7ed9fb5f9fff674bf2ac Mon Sep 17 00:00:00 2001 From: I543501 <56645452+larslutz96@users.noreply.github.com> Date: Wed, 28 Feb 2024 13:36:06 +0100 Subject: [PATCH 2/3] move warning to Data Aggregation --- advanced/odata.md | 4 ++++ node.js/cds-ql.md | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/advanced/odata.md b/advanced/odata.md index eb9f78ab5..5eb1a375a 100644 --- a/advanced/odata.md +++ b/advanced/odata.md @@ -780,6 +780,10 @@ GET /Orders(10)/books? This request operates on the books of the order with ID 10. First it filters out the books from the year 2000 to an intermediate result set. The intermediate result set is then grouped by author name and the price is averaged. Finally, the result set is sorted by title and only the top 3 entries are retained. +::: warning +When using $apply with groupby and only a subset of keys is included, it can lead to the result not being uniquely sorted anymore. +::: + ### Transformations | Transformation | Description | Node.js | Java | diff --git a/node.js/cds-ql.md b/node.js/cds-ql.md index 6bf4bbc04..57bb79231 100644 --- a/node.js/cds-ql.md +++ b/node.js/cds-ql.md @@ -511,9 +511,6 @@ SELECT ... .orderBy ('a.name', 'b desc') SELECT ... .orderBy ({ref:['a','name']}, {ref:['b'],sort:'desc'}) ``` -::: warning -When using $apply with groupby and only a subset of keys is included, it can lead to the result not being uniquely sorted anymore. -::: ### .limit() {.method} From 837d3fec4c557b125419792c71bfeaeb4f99f5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Jeglinsky?= Date: Tue, 26 Mar 2024 08:01:09 +0100 Subject: [PATCH 3/3] Update advanced/odata.md Co-authored-by: Johannes Vogel <31311694+johannes-vogel@users.noreply.github.com> --- advanced/odata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/odata.md b/advanced/odata.md index 5eb1a375a..79e5698a8 100644 --- a/advanced/odata.md +++ b/advanced/odata.md @@ -781,7 +781,7 @@ GET /Orders(10)/books? This request operates on the books of the order with ID 10. First it filters out the books from the year 2000 to an intermediate result set. The intermediate result set is then grouped by author name and the price is averaged. Finally, the result set is sorted by title and only the top 3 entries are retained. ::: warning -When using $apply with groupby and only a subset of keys is included, it can lead to the result not being uniquely sorted anymore. +If the `groupby` transformation only includes a subset of the entity keys, the result order might be unstable. ::: ### Transformations