Skip to content

Commit

Permalink
[ES|QL] Add a standard deviation function (#116531) (#117398)
Browse files Browse the repository at this point in the history
Uses Welford's online algorithm, as well as the parallel version, to
calculate standard deviation.
  • Loading branch information
limotova authored Nov 22, 2024
1 parent 4174c89 commit 04849b0
Show file tree
Hide file tree
Showing 38 changed files with 2,869 additions and 6 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/116531.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 116531
summary: "Add a standard deviation aggregating function: STD_DEV"
area: ES|QL
type: enhancement
issues: []
2 changes: 2 additions & 0 deletions docs/reference/esql/functions/aggregation-functions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The <<esql-stats-by>> command supports these aggregate functions:
* <<esql-min>>
* <<esql-percentile>>
* experimental:[] <<esql-st_centroid_agg>>
* <<esql-std_dev>>
* <<esql-sum>>
* <<esql-top>>
* <<esql-values>>
Expand All @@ -32,6 +33,7 @@ include::layout/median_absolute_deviation.asciidoc[]
include::layout/min.asciidoc[]
include::layout/percentile.asciidoc[]
include::layout/st_centroid_agg.asciidoc[]
include::layout/std_dev.asciidoc[]
include::layout/sum.asciidoc[]
include::layout/top.asciidoc[]
include::layout/values.asciidoc[]
Expand Down
5 changes: 5 additions & 0 deletions docs/reference/esql/functions/description/std_dev.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions docs/reference/esql/functions/examples/std_dev.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions docs/reference/esql/functions/kibana/definition/std_dev.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions docs/reference/esql/functions/kibana/docs/std_dev.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions docs/reference/esql/functions/layout/std_dev.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions docs/reference/esql/functions/parameters/std_dev.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/reference/esql/functions/signature/std_dev.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions docs/reference/esql/functions/types/std_dev.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions x-pack/plugin/esql/compute/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,27 @@ tasks.named('stringTemplates').configure {
it.outputFile = "org/elasticsearch/compute/aggregation/RateDoubleAggregator.java"
}

File stdDevAggregatorInputFile = file("src/main/java/org/elasticsearch/compute/aggregation/X-StdDevAggregator.java.st")
template {
it.properties = intProperties
it.inputFile = stdDevAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/StdDevIntAggregator.java"
}
template {
it.properties = longProperties
it.inputFile = stdDevAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/StdDevLongAggregator.java"
}
template {
it.properties = floatProperties
it.inputFile = stdDevAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/StdDevFloatAggregator.java"
}
template {
it.properties = doubleProperties
it.inputFile = stdDevAggregatorInputFile
it.outputFile = "org/elasticsearch/compute/aggregation/StdDevDoubleAggregator.java"
}

File topAggregatorInputFile = new File("${projectDir}/src/main/java/org/elasticsearch/compute/aggregation/X-TopAggregator.java.st")
template {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 04849b0

Please sign in to comment.