Skip to content

Commit 5559e25

Browse files
authored
Merge branch '8.16' into patch-1
2 parents e422829 + 3ef91e0 commit 5559e25

File tree

15 files changed

+199
-30
lines changed

15 files changed

+199
-30
lines changed

docs/changelog/117297.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 117297
2+
summary: Fix CCS exchange when multi cluster aliases point to same cluster
3+
area: ES|QL
4+
type: bug
5+
issues: []

docs/changelog/117316.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 117316
2+
summary: Fix validation of SORT by aggregate functions
3+
area: ES|QL
4+
type: bug
5+
issues: []

docs/reference/esql/functions/aggregation-functions.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The <<esql-stats-by>> command supports these aggregate functions:
2020
* <<esql-sum>>
2121
* <<esql-top>>
2222
* <<esql-values>>
23-
* experimental:[] <<esql-weighted_avg>>
23+
* <<esql-weighted_avg>>
2424
// end::agg_list[]
2525

2626
include::layout/avg.asciidoc[]

docs/reference/esql/functions/mv-functions.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* <<esql-mv_median>>
2020
* <<esql-mv_median_absolute_deviation>>
2121
* <<esql-mv_min>>
22+
* <<esql-mv_percentile>>
2223
* <<esql-mv_pseries_weighted_sum>>
2324
* <<esql-mv_sort>>
2425
* <<esql-mv_slice>>
@@ -37,6 +38,7 @@ include::layout/mv_max.asciidoc[]
3738
include::layout/mv_median.asciidoc[]
3839
include::layout/mv_median_absolute_deviation.asciidoc[]
3940
include::layout/mv_min.asciidoc[]
41+
include::layout/mv_percentile.asciidoc[]
4042
include::layout/mv_pseries_weighted_sum.asciidoc[]
4143
include::layout/mv_slice.asciidoc[]
4244
include::layout/mv_sort.asciidoc[]

docs/reference/esql/processing-commands/stats.asciidoc

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
[discrete]
22
[[esql-stats-by]]
3-
=== `STATS ... BY`
3+
=== `STATS`
44

5-
The `STATS ... BY` processing command groups rows according to a common value
5+
The `STATS` processing command groups rows according to a common value
66
and calculates one or more aggregated values over the grouped rows.
77

88
**Syntax**
99

1010
[source,esql]
1111
----
12-
STATS [column1 =] expression1[, ..., [columnN =] expressionN]
13-
[BY grouping_expression1[, ..., grouping_expressionN]]
12+
STATS [column1 =] expression1 [WHERE boolean_expression1][,
13+
...,
14+
[columnN =] expressionN [WHERE boolean_expressionN]]
15+
[BY grouping_expression1[, ..., grouping_expressionN]]
1416
----
1517

1618
*Parameters*
@@ -28,14 +30,18 @@ An expression that computes an aggregated value.
2830
An expression that outputs the values to group by.
2931
If its name coincides with one of the computed columns, that column will be ignored.
3032

33+
`boolean_expressionX`::
34+
The condition that must be met for a row to be included in the evaluation of `expressionX`.
35+
3136
NOTE: Individual `null` values are skipped when computing aggregations.
3237

3338
*Description*
3439

35-
The `STATS ... BY` processing command groups rows according to a common value
36-
and calculate one or more aggregated values over the grouped rows. If `BY` is
37-
omitted, the output table contains exactly one row with the aggregations applied
38-
over the entire dataset.
40+
The `STATS` processing command groups rows according to a common value
41+
and calculates one or more aggregated values over the grouped rows. For the
42+
calculation of each aggregated value, the rows in a group can be filtered with
43+
`WHERE`. If `BY` is omitted, the output table contains exactly one row with
44+
the aggregations applied over the entire dataset.
3945

4046
The following <<esql-agg-functions,aggregation functions>> are supported:
4147

@@ -90,6 +96,29 @@ include::{esql-specs}/stats.csv-spec[tag=statsCalcMultipleValues]
9096
include::{esql-specs}/stats.csv-spec[tag=statsCalcMultipleValues-result]
9197
|===
9298

99+
To filter the rows that go into an aggregation, use the `WHERE` clause:
100+
101+
[source.merge.styled,esql]
102+
----
103+
include::{esql-specs}/stats.csv-spec[tag=aggFiltering]
104+
----
105+
[%header.monospaced.styled,format=dsv,separator=|]
106+
|===
107+
include::{esql-specs}/stats.csv-spec[tag=aggFiltering-result]
108+
|===
109+
110+
The aggregations can be mixed, with and without a filter and grouping is
111+
optional as well:
112+
113+
[source.merge.styled,esql]
114+
----
115+
include::{esql-specs}/stats.csv-spec[tag=aggFilteringNoGroup]
116+
----
117+
[%header.monospaced.styled,format=dsv,separator=|]
118+
|===
119+
include::{esql-specs}/stats.csv-spec[tag=aggFilteringNoGroup-result]
120+
|===
121+
93122
[[esql-stats-mv-group]]
94123
If the grouping key is multivalued then the input row is in all groups:
95124

@@ -109,7 +138,7 @@ It's also possible to group by multiple values:
109138
include::{esql-specs}/stats.csv-spec[tag=statsGroupByMultipleValues]
110139
----
111140

112-
If the all grouping keys are multivalued then the input row is in all groups:
141+
If all the grouping keys are multivalued then the input row is in all groups:
113142

114143
[source.merge.styled,esql]
115144
----
@@ -121,7 +150,7 @@ include::{esql-specs}/stats.csv-spec[tag=multi-mv-group-result]
121150
|===
122151

123152
Both the aggregating functions and the grouping expressions accept other
124-
functions. This is useful for using `STATS...BY` on multivalue columns.
153+
functions. This is useful for using `STATS` on multivalue columns.
125154
For example, to calculate the average salary change, you can use `MV_AVG` to
126155
first average the multiple values per employee, and use the result with the
127156
`AVG` function:

docs/reference/release-notes/8.16.1.asciidoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[[release-notes-8.16.1]]
22
== {es} version 8.16.1
33

4-
coming[8.16.1]
5-
64
Also see <<breaking-changes-8.16,Breaking changes in 8.16>>.
75

86
[[bug-8.16.1]]

muted-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ tests:
286286
- class: org.elasticsearch.ingest.geoip.EnterpriseGeoIpDownloaderIT
287287
method: testEnterpriseDownloaderTask
288288
issue: https://github.com/elastic/elasticsearch/issues/115163
289+
- class: org.elasticsearch.xpack.inference.InferenceRestIT
290+
method: test {p0=inference/40_semantic_text_query/Query a field that uses the default ELSER 2 endpoint}
291+
issue: https://github.com/elastic/elasticsearch/issues/117027
289292

290293
# Examples:
291294
#

test/framework/src/main/java/org/elasticsearch/test/AbstractMultiClustersTestCase.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.client.internal.Client;
1818
import org.elasticsearch.common.network.NetworkModule;
1919
import org.elasticsearch.common.settings.Settings;
20+
import org.elasticsearch.common.transport.TransportAddress;
2021
import org.elasticsearch.core.IOUtils;
2122
import org.elasticsearch.core.Strings;
2223
import org.elasticsearch.plugins.Plugin;
@@ -44,6 +45,7 @@
4445

4546
import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING;
4647
import static org.elasticsearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING;
48+
import static org.hamcrest.Matchers.contains;
4749
import static org.hamcrest.Matchers.empty;
4850
import static org.hamcrest.Matchers.hasKey;
4951
import static org.hamcrest.Matchers.not;
@@ -149,19 +151,23 @@ public static void stopClusters() throws IOException {
149151
}
150152

151153
protected void disconnectFromRemoteClusters() throws Exception {
152-
Settings.Builder settings = Settings.builder();
153154
final Set<String> clusterAliases = clusterGroup.clusterAliases();
154155
for (String clusterAlias : clusterAliases) {
155156
if (clusterAlias.equals(LOCAL_CLUSTER) == false) {
156-
settings.putNull("cluster.remote." + clusterAlias + ".seeds");
157-
settings.putNull("cluster.remote." + clusterAlias + ".mode");
158-
settings.putNull("cluster.remote." + clusterAlias + ".proxy_address");
157+
removeRemoteCluster(clusterAlias);
159158
}
160159
}
160+
}
161+
162+
protected void removeRemoteCluster(String clusterAlias) throws Exception {
163+
Settings.Builder settings = Settings.builder();
164+
settings.putNull("cluster.remote." + clusterAlias + ".seeds");
165+
settings.putNull("cluster.remote." + clusterAlias + ".mode");
166+
settings.putNull("cluster.remote." + clusterAlias + ".proxy_address");
161167
client().admin().cluster().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).setPersistentSettings(settings).get();
162168
assertBusy(() -> {
163169
for (TransportService transportService : cluster(LOCAL_CLUSTER).getInstances(TransportService.class)) {
164-
assertThat(transportService.getRemoteClusterService().getRegisteredRemoteClusterNames(), empty());
170+
assertThat(transportService.getRemoteClusterService().getRegisteredRemoteClusterNames(), not(contains(clusterAlias)));
165171
}
166172
});
167173
}
@@ -178,12 +184,17 @@ protected void configureAndConnectsToRemoteClusters() throws Exception {
178184
}
179185

180186
protected void configureRemoteCluster(String clusterAlias, Collection<String> seedNodes) throws Exception {
181-
final String remoteClusterSettingPrefix = "cluster.remote." + clusterAlias + ".";
182-
Settings.Builder settings = Settings.builder();
183-
final List<String> seedAddresses = seedNodes.stream().map(node -> {
187+
final var seedAddresses = seedNodes.stream().map(node -> {
184188
final TransportService transportService = cluster(clusterAlias).getInstance(TransportService.class, node);
185-
return transportService.boundAddress().publishAddress().toString();
189+
return transportService.boundAddress().publishAddress();
186190
}).toList();
191+
configureRemoteClusterWithSeedAddresses(clusterAlias, seedAddresses);
192+
}
193+
194+
protected void configureRemoteClusterWithSeedAddresses(String clusterAlias, Collection<TransportAddress> seedNodes) throws Exception {
195+
final String remoteClusterSettingPrefix = "cluster.remote." + clusterAlias + ".";
196+
Settings.Builder settings = Settings.builder();
197+
final List<String> seedAddresses = seedNodes.stream().map(TransportAddress::toString).toList();
187198
boolean skipUnavailable = skipUnavailableForRemoteClusters().containsKey(clusterAlias)
188199
? skipUnavailableForRemoteClusters().get(clusterAlias)
189200
: DEFAULT_SKIP_UNAVAILABLE;

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/exchange/ExchangeService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
import java.io.IOException;
4242
import java.util.Map;
43+
import java.util.Set;
4344
import java.util.concurrent.Executor;
4445
import java.util.concurrent.atomic.AtomicLong;
4546

@@ -339,6 +340,10 @@ public boolean isEmpty() {
339340
return sinks.isEmpty();
340341
}
341342

343+
public Set<String> sinkKeys() {
344+
return sinks.keySet();
345+
}
346+
342347
@Override
343348
protected void doStart() {
344349

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,6 +2318,42 @@ v:integer | job_positions:keyword
23182318
10094 | Accountant
23192319
;
23202320

2321+
docsStatsWithSimpleFiltering
2322+
required_capability: per_agg_filtering
2323+
// tag::aggFiltering[]
2324+
FROM employees
2325+
| STATS avg50s = AVG(salary)::LONG WHERE birth_date < "1960-01-01",
2326+
avg60s = AVG(salary)::LONG WHERE birth_date >= "1960-01-01"
2327+
BY gender
2328+
| SORT gender
2329+
// end::aggFiltering[]
2330+
| WHERE gender IS NOT NULL
2331+
;
2332+
2333+
// tag::aggFiltering-result[]
2334+
avg50s:long |avg60s:long |gender:keyword
2335+
55462 |46637 |F
2336+
48279 |44879 |M
2337+
// end::aggFiltering-result[]
2338+
;
2339+
2340+
docsStatsWithFilteringNoGroups
2341+
required_capability: per_agg_filtering
2342+
// tag::aggFilteringNoGroup[]
2343+
FROM employees
2344+
| EVAL Ks = salary / 1000 // thousands
2345+
| STATS under_40K = COUNT(*) WHERE Ks < 40,
2346+
inbetween = COUNT(*) WHERE 40 <= Ks AND Ks < 60,
2347+
over_60K = COUNT(*) WHERE 60 <= Ks,
2348+
total = COUNT(*)
2349+
// end::aggFilteringNoGroup[]
2350+
;
2351+
2352+
// tag::aggFilteringNoGroup-result[]
2353+
under_40K:long |inbetween:long |over_60K:long |total:long
2354+
36 |39 |25 |100
2355+
// end::aggFilteringNoGroup-result[]
2356+
;
23212357

23222358
statsWithFiltering
23232359
required_capability: per_agg_filtering

0 commit comments

Comments
 (0)