Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.util.Objects;
import java.util.function.IntFunction;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.joining;
Expand Down Expand Up @@ -325,7 +326,11 @@ private static void checkState(boolean condition, String msg) {

@Override
public String toString() {
return this.getClass().getSimpleName() + "[" + "aggregators=" + aggregatorFactories + "]";
String aggregatorDescriptions = aggregatorFactories.stream()
.map(factory -> "\"" + factory.describe() + "\"")
.collect(Collectors.joining(", "));

return this.getClass().getSimpleName() + "[" + "aggregators=[" + aggregatorDescriptions + "]]";
}

record SegmentID(int shardIndex, int segmentIndex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,35 @@ public void testProfile() throws IOException {
);
}

public void testProfileOrdinalsGroupingOperator() throws IOException {
indexTimestampData(1);

RequestObjectBuilder builder = requestObjectBuilder().query(fromIndex() + " | STATS AVG(value) BY test.keyword");
builder.profile(true);
if (Build.current().isSnapshot()) {
// Lock to shard level partitioning, so we get consistent profile output
builder.pragmas(Settings.builder().put("data_partitioning", "shard").build());
}
Map<String, Object> result = runEsql(builder);

List<List<String>> signatures = new ArrayList<>();
@SuppressWarnings("unchecked")
List<Map<String, Object>> profiles = (List<Map<String, Object>>) ((Map<String, Object>) result.get("profile")).get("drivers");
for (Map<String, Object> p : profiles) {
fixTypesOnProfile(p);
assertThat(p, commonProfile());
List<String> sig = new ArrayList<>();
@SuppressWarnings("unchecked")
List<Map<String, Object>> operators = (List<Map<String, Object>>) p.get("operators");
for (Map<String, Object> o : operators) {
sig.add((String) o.get("operator"));
}
signatures.add(sig);
}

assertThat(signatures.get(0).get(2), equalTo("OrdinalsGroupingOperator[aggregators=[\"sum of longs\", \"count\"]]"));
}

public void testInlineStatsProfile() throws IOException {
assumeTrue("INLINESTATS only available on snapshots", Build.current().isSnapshot());
indexTimestampData(1);
Expand Down