Skip to content

Commit c8cc2e0

Browse files
authored
ESQL: Add support for exponential_histogram as case value (#138300)
1 parent 1967753 commit c8cc2e0

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/resources/exponential_histogram.csv-spec

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ NULL | NULL | NULL
8282
;
8383

8484

85+
histoAsCaseValue
86+
required_capability: exponential_histogram_minmax_support
87+
88+
FROM exp_histo_sample
89+
| INLINE STATS p50 = PERCENTILE(responseTime, 50) BY instance, @timestamp
90+
| EVAL filteredHisto = CASE(p50 > 0.1, responseTime)
91+
| INLINE STATS filteredMax = MAX(filteredHisto) BY instance, @timestamp //MAX is null if the histogram is null
92+
| STATS filteredCount = COUNT(filteredMax)
93+
;
94+
95+
filteredCount:long
96+
3
97+
;
8598

8699
ungroupedPercentiles
87100
required_capability: exponential_histogram_percentiles_support

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ ConditionEvaluatorSupplier toEvaluator(ToEvaluator toEvaluator) {
8181
"keyword",
8282
"long",
8383
"unsigned_long",
84-
"version" },
84+
"version",
85+
"exponential_histogram" },
8586
description = """
8687
Accepts pairs of conditions and values. The function returns the value that
8788
belongs to the first condition that evaluates to `true`.
@@ -126,7 +127,8 @@ public Case(
126127
"long",
127128
"text",
128129
"unsigned_long",
129-
"version" },
130+
"version",
131+
"exponential_histogram" },
130132
description = "The value that’s returned when the corresponding condition is the first to evaluate to `true`. "
131133
+ "The default value is returned when no condition matches."
132134
) List<Expression> rest

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public class CaseTests extends AbstractScalarFunctionTestCase {
6666
if (Build.current().isSnapshot()) {
6767
t.addAll(
6868
DataType.UNDER_CONSTRUCTION.stream()
69-
.filter(type -> type != DataType.EXPONENTIAL_HISTOGRAM) // TODO(b/133393): implement
7069
.filter(type -> type != DataType.AGGREGATE_METRIC_DOUBLE && type != DataType.DENSE_VECTOR)
7170
.toList()
7271
);

0 commit comments

Comments
 (0)