From 6c5f556ad8589728620009c5e0aeaedba8fedc7b Mon Sep 17 00:00:00 2001 From: Marios Trivyzas Date: Fri, 1 Feb 2019 15:48:32 +0200 Subject: [PATCH 1/2] SQL: [Docs] Add limitation for aggregate functions on scalars Currently aggregate functions can operate only directly on fields. They cannot be used on top of scalar functions as painless scripting is currently not supported. --- docs/reference/sql/limitations.asciidoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/reference/sql/limitations.asciidoc b/docs/reference/sql/limitations.asciidoc index 39b7c191131ff..8aceb62d72625 100644 --- a/docs/reference/sql/limitations.asciidoc +++ b/docs/reference/sql/limitations.asciidoc @@ -70,6 +70,12 @@ When doing aggregations (`GROUP BY`) {es-sql} relies on {es}'s `composite` aggre But this type of aggregation does come with a limitation: sorting can only be applied on the key used for the aggregation's buckets. This means that queries like `SELECT * FROM test GROUP BY age ORDER BY COUNT(*)` are not possible. +[float] +=== Use aggregation functions on top of scalar functions + +Aggregation functions like <>, <>, etc. can only be used +directly on fields, and so queries like `SELECT MAX(abs(age)) FROM test` are not possible. + [float] === Using a sub-select From 35b73321c4db68b09007f65689855679bacdefff Mon Sep 17 00:00:00 2001 From: Marios Trivyzas Date: Fri, 1 Feb 2019 16:00:30 +0200 Subject: [PATCH 2/2] Address comment --- docs/reference/sql/limitations.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/sql/limitations.asciidoc b/docs/reference/sql/limitations.asciidoc index 8aceb62d72625..8104580e2998c 100644 --- a/docs/reference/sql/limitations.asciidoc +++ b/docs/reference/sql/limitations.asciidoc @@ -71,7 +71,7 @@ But this type of aggregation does come with a limitation: sorting can only be ap means that queries like `SELECT * FROM test GROUP BY age ORDER BY COUNT(*)` are not possible. [float] -=== Use aggregation functions on top of scalar functions +=== Using aggregation functions on top of scalar functions Aggregation functions like <>, <>, etc. can only be used directly on fields, and so queries like `SELECT MAX(abs(age)) FROM test` are not possible. @@ -98,7 +98,7 @@ But, if the sub-select would include a `GROUP BY` or `HAVING` or the enclosing ` FROM (SELECT ...) WHERE [simple_condition]`, this is currently **un-supported**. [float] -=== Use <>/<> aggregation functions in `HAVING` clause +=== Using <>/<> aggregation functions in `HAVING` clause Using `FIRST` and `LAST` in the `HAVING` clause is not supported. The same applies to <> and <> when their target column