Skip to content

Conversation

@limotova
Copy link
Contributor

@limotova limotova commented Jun 9, 2025

The bulk of this PR is generated code
For ease of reading, the first 4 commits are split into the following components:

  • Generated files for STD_DEV_SAMPLE, VARIANCE_POPULATION, and VARIANCE_SAMPLE (all new functions)
  • Generated files for STD_DEV (the previously existing function)
  • Tests
  • Manually written files (including the template files)

Currently ES|QL only has a population standard deviation aggregation STD_DEV available.
This PR adds in STD_DEV_SAMPLE, VARIANCE_POPULATION, and VARIANCE_SAMPLE functions by expanding the original X-StdDevAggregator.java.st template to output each of the 4 variations, as well as introducing a X-StdDev.java.st to generate the AggregateFunction classes for all 4.

@limotova limotova force-pushed the add-stddev-population branch from 0630a50 to 9a5b800 Compare June 9, 2025 08:34
@limotova limotova force-pushed the add-stddev-population branch from 2690c24 to 08feb83 Compare June 9, 2025 15:45
@limotova limotova force-pushed the add-stddev-population branch from 08feb83 to 58d858a Compare June 9, 2025 18:10
@limotova limotova force-pushed the add-stddev-population branch from 58d858a to 6450343 Compare June 9, 2025 18:12
@limotova limotova changed the title Add stddev population ES|QL Add variations of standard deviation functions Jun 9, 2025
@limotova limotova changed the title ES|QL Add variations of standard deviation functions [ES|QL] Add variations of standard deviation functions Jun 9, 2025
@limotova limotova force-pushed the add-stddev-population branch from 6450343 to 4b3866a Compare June 9, 2025 18:50
@limotova limotova force-pushed the add-stddev-population branch from 4b3866a to 2b7feb0 Compare June 10, 2025 05:36
@limotova limotova force-pushed the add-stddev-population branch from 2b7feb0 to 356dec3 Compare June 23, 2025 13:58
@github-actions
Copy link
Contributor

github-actions bot commented Jun 23, 2025

🔍 Preview links for changed docs:

🔔 The preview site may take up to 3 minutes to finish building. These links will become live once it completes.

@limotova limotova requested a review from dnhatn June 24, 2025 08:34
Copy link
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Larisa!

def(Top.class, tri(Top::new), "top"),
def(Values.class, uni(Values::new), "values"),
def(VariancePopulation.class, uni(VariancePopulation::new), "variance_population"),
def(VarianceSample.class, uni(VarianceSample::new), "variance_sample"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be sample_variance?

def(Sum.class, uni(Sum::new), "sum"),
def(Top.class, tri(Top::new), "top"),
def(Values.class, uni(Values::new), "values"),
def(VariancePopulation.class, uni(VariancePopulation::new), "variance_population"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be population_variance?

import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isType;

public class $Variation$ extends AggregateFunction implements ToAggregator {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

public final AggregatorFunctionSupplier supplier() {
DataType type = field().dataType();
if (type == DataType.LONG) {
return new $Variation$LongAggregatorFunctionSupplier();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a new parameter for the variance type to the aggregator (see CountDistinctIntAggregator) so we don't have to generate similar classes multiple times? This approach is also fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants