Browse Source

[ES|QL] add tests for stats by constant (#110593)

* add tests for stats by constant
Fang Xing 1 năm trước cách đây
mục cha
commit
91fb6e938d

+ 6 - 0
docs/changelog/110593.yaml

@@ -0,0 +1,6 @@
+pr: 110593
+summary: "[ES|QL] add tests for stats by constant"
+area: ES|QL
+type: bug
+issues:
+ - 105383

+ 32 - 0
x-pack/plugin/esql/qa/testFixtures/src/main/resources/stats.csv-spec

@@ -1913,3 +1913,35 @@ MIN(i):integer | a:keyword | b:integer
              1 | b         | 3
 // end::multi-mv-group-result[]
 ;
+
+statsByConstant
+required_capability: stats_by_constant
+from employees
+| stats m = max(salary), a = round(avg(salary)) by 0
+;
+
+m:integer |a:double |0:integer
+74999     |48249.0  |0
+;
+
+statsByConstantFromStats
+required_capability: stats_by_constant
+from employees
+| stats c = count(languages)
+| stats a = count(*) by c
+;
+
+a:long |c:long
+1      |90
+;
+
+statsByConstantFromEval
+required_capability: stats_by_constant
+from employees
+| eval x = 0
+| stats m = max(salary), a = round(avg(salary)) by x
+;
+
+m:integer |a:double |x:integer
+74999     |48249.0  |0
+;

+ 6 - 1
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

@@ -154,7 +154,12 @@ public class EsqlCapabilities {
         /**
         * Use RangeQuery for BinaryComparison on DateTime fields.
         * */
-        RANGEQUERY_FOR_DATETIME;
+        RANGEQUERY_FOR_DATETIME,
+
+        /**
+         * Add tests for #105383, STATS BY constant.
+         */
+        STATS_BY_CONSTANT;
 
         private final boolean snapshotOnly;