Skip to content

Commit

Permalink
Fix suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
trzysiek committed Sep 23, 2024
1 parent 77a80a3 commit dc45c02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions quesma/queryparser/pancake_sql_query_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ func (p *pancakeSqlQueryGenerator) generateAccumAggrFunctions(origExpr model.Exp
return model.NewFunction(origFunc.Name+"State", origFunc.Args...), origFunc.Name + "Merge", nil
}

// We use sumArray here, because "quantiles" returns an array.
// We probably could simplify the code a bit to use "quantile" instead, and just "sum" here.
if strings.HasPrefix(origFunc.Name, "quantiles") {
return origFunc, "sumArray", nil
return model.NewFunction(strings.Replace(origFunc.Name, "quantiles", "quantilesState", 1), origFunc.Args...),
strings.Replace(origFunc.Name, "quantiles", "quantilesMerge", 1), nil
}
}
debugQueryType := "<nil>"
Expand Down
8 changes: 4 additions & 4 deletions quesma/testdata/kibana-visualize/aggregation_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -1040,10 +1040,10 @@ var AggregationTests = []testdata.AggregationTestCase{
SELECT sum(count(*)) OVER () AS "aggr__0__parent_count",
"Cancelled" AS "aggr__0__key_0",
sum(count(*)) OVER (PARTITION BY "aggr__0__key_0") AS "aggr__0__count",
sumArray(quantiles(0.950000)("DistanceKilometers")) OVER (PARTITION BY
"aggr__0__key_0") AS "aggr__0__order_1",
sumArray(quantiles(0.950000)("DistanceKilometers")) OVER (PARTITION BY
"aggr__0__key_0") AS "metric__0__2_col_0",
quantilesMerge(0.950000)(quantilesState(0.950000)("DistanceKilometers"))
OVER (PARTITION BY "aggr__0__key_0") AS "aggr__0__order_1",
quantilesMerge(0.950000)(quantilesState(0.950000)("DistanceKilometers"))
OVER (PARTITION BY "aggr__0__key_0") AS "metric__0__2_col_0",
floor("DistanceKilometers"/5000)*5000 AS "aggr__0__1__key_0",
count(*) AS "aggr__0__1__count",
quantiles(0.950000)("DistanceKilometers") AS "metric__0__1__2_col_0"
Expand Down

0 comments on commit dc45c02

Please sign in to comment.