From 28e911be4f6dda773d1eaf420dcafaf434db6a5c Mon Sep 17 00:00:00 2001 From: Krzysztof Kiewicz Date: Wed, 22 May 2024 14:23:00 +0200 Subject: [PATCH] `Sum_bucket` aggregation (#156) Tests to this PR showed 2 issues in all pipeline aggregations: * we should stop log warnings when numeric values are null * so far all pipeline aggregation's "parent" was at the same level of nesting. But it doesn't have to be the case, I'll need to fix this, it shouldn't be very hard. I comment out the test for this so far. But especially as those are issues in all types of pipeline aggr, I'd fix those in separate PR. Some screens: Screenshot 2024-05-20 at 12 07 50 Screenshot 2024-05-20 at 12 08 29 --- .../pipeline_aggregations/average_bucket.go | 3 + .../model/pipeline_aggregations/derivative.go | 2 +- .../model/pipeline_aggregations/min_bucket.go | 10 +- .../model/pipeline_aggregations/sum_bucket.go | 117 +++ quesma/queryparser/aggregation_parser_test.go | 5 +- quesma/queryparser/pipeline_aggregations.go | 20 + .../pipeline_aggregation_requests.go | 991 +++++++++++++++++- quesma/testdata/unsupported_requests.go | 28 - 8 files changed, 1140 insertions(+), 36 deletions(-) create mode 100644 quesma/model/pipeline_aggregations/sum_bucket.go diff --git a/quesma/model/pipeline_aggregations/average_bucket.go b/quesma/model/pipeline_aggregations/average_bucket.go index 2666d973a..e49579f97 100644 --- a/quesma/model/pipeline_aggregations/average_bucket.go +++ b/quesma/model/pipeline_aggregations/average_bucket.go @@ -43,6 +43,9 @@ func (query AverageBucket) CalculateResultWhenMissing(qwa *model.Query, parentRo parentFieldsCnt := len(parentRows[0].Cols) - 2 // -2, because row is [parent_cols..., current_key, current_value] // in calculateSingleAvgBucket we calculate avg all current_keys with the same parent_cols // so we need to split into buckets based on parent_cols + if parentFieldsCnt < 0 { + logger.WarnWithCtx(query.ctx).Msgf("parentFieldsCnt is less than 0: %d", parentFieldsCnt) + } for _, parentRowsOneBucket := range qp.SplitResultSetIntoBuckets(parentRows, parentFieldsCnt) { resultRows = append(resultRows, query.calculateSingleAvgBucket(parentRowsOneBucket)) } diff --git a/quesma/model/pipeline_aggregations/derivative.go b/quesma/model/pipeline_aggregations/derivative.go index 0a3921327..695490032 100644 --- a/quesma/model/pipeline_aggregations/derivative.go +++ b/quesma/model/pipeline_aggregations/derivative.go @@ -78,7 +78,7 @@ func (query Derivative) CalculateResultWhenMissing(qwa *model.Query, parentRows if okPrevious && okCurrent { resultValue = currentValue - previousValue } else { - logger.WarnWithCtx(query.ctx).Msgf("could not convert value to float: previousValue: %v, type: %T; currentValue: %v, type: %T. Skipping", + logger.WarnWithCtx(query.ctx).Msgf("could not convert value to int: previousValue: %v, type: %T; currentValue: %v, type: %T. Skipping", previousValueRaw, previousValueRaw, currentValueRaw, currentValueRaw) resultValue = nil } diff --git a/quesma/model/pipeline_aggregations/min_bucket.go b/quesma/model/pipeline_aggregations/min_bucket.go index 8bff12122..96b7df91a 100644 --- a/quesma/model/pipeline_aggregations/min_bucket.go +++ b/quesma/model/pipeline_aggregations/min_bucket.go @@ -33,10 +33,9 @@ func (query MinBucket) TranslateSqlResponseToJson(rows []model.QueryResultRow, l } if returnMap, ok := rows[0].LastColValue().(model.JsonMap); ok { return []model.JsonMap{returnMap} - } else { - logger.WarnWithCtx(query.ctx).Msgf("could not convert value to JsonMap: %v, type: %T", rows[0].LastColValue(), rows[0].LastColValue()) - return []model.JsonMap{nil} } + logger.WarnWithCtx(query.ctx).Msgf("could not convert value to JsonMap: %v, type: %T", rows[0].LastColValue(), rows[0].LastColValue()) + return []model.JsonMap{nil} } func (query MinBucket) CalculateResultWhenMissing(qwa *model.Query, parentRows []model.QueryResultRow) []model.QueryResultRow { @@ -48,6 +47,9 @@ func (query MinBucket) CalculateResultWhenMissing(qwa *model.Query, parentRows [ parentFieldsCnt := len(parentRows[0].Cols) - 2 // -2, because row is [parent_cols..., current_key, current_value] // in calculateSingleAvgBucket we calculate avg all current_keys with the same parent_cols // so we need to split into buckets based on parent_cols + if parentFieldsCnt < 0 { + logger.WarnWithCtx(query.ctx).Msgf("parentFieldsCnt is less than 0: %d", parentFieldsCnt) + } for _, parentRowsOneBucket := range qp.SplitResultSetIntoBuckets(parentRows, parentFieldsCnt) { resultRows = append(resultRows, query.calculateSingleMinBucket(qwa, parentRowsOneBucket)) } @@ -84,7 +86,7 @@ func (query MinBucket) calculateSingleMinBucket(qwa *model.Query, parentRows []m if ok { minValue = min(minValue, value) } else { - logger.WarnWithCtx(query.ctx).Msgf("could not convert value to float: %v, type: %T. Skipping", row.LastColValue(), row.LastColValue()) + logger.WarnWithCtx(query.ctx).Msgf("could not convert value to int: %v, type: %T. Skipping", row.LastColValue(), row.LastColValue()) } } resultValue = minValue diff --git a/quesma/model/pipeline_aggregations/sum_bucket.go b/quesma/model/pipeline_aggregations/sum_bucket.go new file mode 100644 index 000000000..c97f0eda2 --- /dev/null +++ b/quesma/model/pipeline_aggregations/sum_bucket.go @@ -0,0 +1,117 @@ +package pipeline_aggregations + +import ( + "context" + "fmt" + "mitmproxy/quesma/logger" + "mitmproxy/quesma/model" + "mitmproxy/quesma/queryprocessor" + "mitmproxy/quesma/util" +) + +type SumBucket struct { + ctx context.Context + Parent string +} + +func NewSumBucket(ctx context.Context, bucketsPath string) SumBucket { + return SumBucket{ctx: ctx, Parent: parseBucketsPathIntoParentAggregationName(ctx, bucketsPath)} +} + +func (query SumBucket) IsBucketAggregation() bool { + return false +} + +func (query SumBucket) TranslateSqlResponseToJson(rows []model.QueryResultRow, level int) []model.JsonMap { + if len(rows) == 0 { + logger.WarnWithCtx(query.ctx).Msg("no rows returned for average bucket aggregation") + return []model.JsonMap{nil} + } + if len(rows) > 1 { + logger.WarnWithCtx(query.ctx).Msg("more than one row returned for average bucket aggregation") + } + if returnMap, ok := rows[0].LastColValue().(model.JsonMap); ok { + return []model.JsonMap{returnMap} + } + logger.WarnWithCtx(query.ctx).Msgf("could not convert value to JsonMap: %v, type: %T", rows[0].LastColValue(), rows[0].LastColValue()) + return []model.JsonMap{nil} +} + +func (query SumBucket) CalculateResultWhenMissing(qwa *model.Query, parentRows []model.QueryResultRow) []model.QueryResultRow { + resultRows := make([]model.QueryResultRow, 0) + if len(parentRows) == 0 { + return resultRows // maybe null? + } + qp := queryprocessor.NewQueryProcessor(query.ctx) + parentFieldsCnt := len(parentRows[0].Cols) - 2 // -2, because row is [parent_cols..., current_key, current_value] + // in calculateSingleAvgBucket we calculate avg all current_keys with the same parent_cols + // so we need to split into buckets based on parent_cols + if parentFieldsCnt < 0 { + logger.WarnWithCtx(query.ctx).Msgf("parentFieldsCnt is less than 0: %d", parentFieldsCnt) + } + for _, parentRowsOneBucket := range qp.SplitResultSetIntoBuckets(parentRows, parentFieldsCnt) { + resultRows = append(resultRows, query.calculateSingleSumBucket(parentRowsOneBucket)) + } + return resultRows +} + +// we're sure len(parentRows) > 0 +func (query SumBucket) calculateSingleSumBucket(parentRows []model.QueryResultRow) model.QueryResultRow { + var resultValue any + + firstNonNilIndex := -1 + for i, row := range parentRows { + if row.LastColValue() != nil { + firstNonNilIndex = i + break + } + } + if firstNonNilIndex == -1 { + resultRow := parentRows[0].Copy() + resultRow.Cols[len(resultRow.Cols)-1].Value = model.JsonMap{ + "value": resultValue, + } + return resultRow + } + + if firstRowValueFloat, firstRowValueIsFloat := util.ExtractFloat64Maybe(parentRows[firstNonNilIndex].LastColValue()); firstRowValueIsFloat { + sum := firstRowValueFloat + for _, row := range parentRows[firstNonNilIndex+1:] { + value, ok := util.ExtractFloat64Maybe(row.LastColValue()) + if ok { + sum += value + } else { + logger.WarnWithCtx(query.ctx).Msgf("could not convert value to float: %v, type: %T. Skipping", row.LastColValue(), row.LastColValue()) + } + } + resultValue = sum + } else if firstRowValueInt, firstRowValueIsInt := util.ExtractInt64Maybe(parentRows[firstNonNilIndex].LastColValue()); firstRowValueIsInt { + sum := firstRowValueInt + for _, row := range parentRows[firstNonNilIndex+1:] { + value, ok := util.ExtractInt64Maybe(row.LastColValue()) + if ok { + sum += value + } else { + logger.WarnWithCtx(query.ctx).Msgf("could not convert value to int: %v, type: %T. Skipping", row.LastColValue(), row.LastColValue()) + } + } + resultValue = sum + } else { + logger.WarnWithCtx(query.ctx).Msgf("could not convert value to float or int: %v, type: %T. Returning nil.", + parentRows[firstNonNilIndex].LastColValue(), parentRows[firstNonNilIndex].LastColValue()) + } + + resultRow := parentRows[0].Copy() + resultRow.Cols[len(resultRow.Cols)-1].Value = model.JsonMap{ + "value": resultValue, + } + return resultRow +} + +func (query SumBucket) PostprocessResults(rowsFromDB []model.QueryResultRow) []model.QueryResultRow { + return rowsFromDB +} + +func (query SumBucket) String() string { + return fmt.Sprintf("sum_bucket(%s)", query.Parent) +} diff --git a/quesma/queryparser/aggregation_parser_test.go b/quesma/queryparser/aggregation_parser_test.go index 7a5b35ae2..3902d950a 100644 --- a/quesma/queryparser/aggregation_parser_test.go +++ b/quesma/queryparser/aggregation_parser_test.go @@ -577,9 +577,12 @@ func Test2AggregationParserExternalTestcases(t *testing.T) { allTests = append(allTests, opensearch_visualize.PipelineAggregationTests...) for i, test := range allTests { t.Run(test.TestName+"("+strconv.Itoa(i)+")", func(t *testing.T) { - if i == 57 { + if test.TestName == "Max/Sum bucket with some null buckets. Reproduce: Visualize -> Vertical Bar: Metrics: Max (Sum) Bucket (Aggregation: Date Histogram, Metric: Min)" { t.Skip("Needs to be fixed by keeping last key for every aggregation. Now we sometimes don't know it. Hard to reproduce, leaving it for separate PR") } + if test.TestName == "complex sum_bucket. Reproduce: Visualize -> Vertical Bar: Metrics: Sum Bucket (Bucket: Date Histogram, Metric: Average), Buckets: X-Asis: Histogram" { + t.Skip("Waiting for fix. Now we handle only the case where pipeline agg is at the same nesting level as its parent. Should be quick to fix.") + } if i > 26 && i <= 30 { t.Skip("New tests, harder, failing for now. Fixes for them in 2 next PRs") } diff --git a/quesma/queryparser/pipeline_aggregations.go b/quesma/queryparser/pipeline_aggregations.go index 7a27ef8fd..de9fc9f25 100644 --- a/quesma/queryparser/pipeline_aggregations.go +++ b/quesma/queryparser/pipeline_aggregations.go @@ -31,6 +31,11 @@ func (cw *ClickhouseQueryTranslator) parsePipelineAggregations(queryMap QueryMap } if aggregationType, success = cw.parseMaxBucket(queryMap); success { delete(queryMap, "max_bucket") + return + } + if aggregationType, success = cw.parseSumBucket(queryMap); success { + delete(queryMap, "sum_bucket") + return } return } @@ -95,6 +100,18 @@ func (cw *ClickhouseQueryTranslator) parseMaxBucket(queryMap QueryMap) (aggregat return pipeline_aggregations.NewMaxBucket(cw.Ctx, bucketsPath), true } +func (cw *ClickhouseQueryTranslator) parseSumBucket(queryMap QueryMap) (aggregationType model.QueryType, success bool) { + sumBucketRaw, exists := queryMap["sum_bucket"] + if !exists { + return + } + bucketsPath, ok := cw.parseBucketsPath(sumBucketRaw, "sum_bucket") + if !ok { + return + } + return pipeline_aggregations.NewSumBucket(cw.Ctx, bucketsPath), true +} + func (cw *ClickhouseQueryTranslator) parseBucketScriptBasic(queryMap QueryMap) (aggregationType model.QueryType, success bool) { bucketScriptRaw, exists := queryMap["bucket_script"] if !exists { @@ -205,6 +222,9 @@ func (b *aggrQueryBuilder) finishBuildingAggregationPipeline(aggregationType mod case pipeline_aggregations.MaxBucket: query.NoDBQuery = true query.Parent = aggrType.Parent + case pipeline_aggregations.SumBucket: + query.NoDBQuery = true + query.Parent = aggrType.Parent } return query } diff --git a/quesma/testdata/opensearch-visualize/pipeline_aggregation_requests.go b/quesma/testdata/opensearch-visualize/pipeline_aggregation_requests.go index 8003dcc48..f47d58136 100644 --- a/quesma/testdata/opensearch-visualize/pipeline_aggregation_requests.go +++ b/quesma/testdata/opensearch-visualize/pipeline_aggregation_requests.go @@ -2677,7 +2677,7 @@ var PipelineAggregationTests = []testdata.AggregationTestCase{ }, }, { // [15] - TestName: "Max bucket with some null buckets. Reproduce: Visualize -> Vertical Bar: Metrics: Max Bucket (Aggregation: Date Histogram, Metric: Min)", + TestName: "Max/Sum bucket with some null buckets. Reproduce: Visualize -> Vertical Bar: Metrics: Max (Sum) Bucket (Aggregation: Date Histogram, Metric: Min)", QueryRequestJson: ` { "_source": { @@ -2689,6 +2689,11 @@ var PipelineAggregationTests = []testdata.AggregationTestCase{ "buckets_path": "1-bucket>1-metric" } }, + "2":{ + "sum_bucket": { + "buckets_path": "1-bucket>1-metric" + } + }, "1-bucket": { "aggs": { "1-metric": { @@ -2759,6 +2764,9 @@ var PipelineAggregationTests = []testdata.AggregationTestCase{ ], "value": 121360.0 }, + "2": { + "dunno": "check in opensearch and add this" + }, "1-bucket": { "buckets": [ { @@ -2848,7 +2856,7 @@ var PipelineAggregationTests = []testdata.AggregationTestCase{ }, }, { // [16] - TestName: "Max bucket with some null buckets. Reproduce: Visualize -> Vertical Bar: Metrics: Max Bucket (Aggregation: Histogram, Metric: Max)", + TestName: "Max/Sum bucket with some null buckets. Reproduce: Visualize -> Vertical Bar: Metrics: Max/Sum Bucket (Aggregation: Histogram, Metric: Max)", QueryRequestJson: ` { "_source": { @@ -2860,6 +2868,11 @@ var PipelineAggregationTests = []testdata.AggregationTestCase{ "buckets_path": "1-bucket>1-metric" } }, + "2":{ + "sum_bucket": { + "buckets_path": "1-bucket>1-metric" + } + }, "1-bucket": { "aggs": { "1-metric": { @@ -2930,6 +2943,10 @@ var PipelineAggregationTests = []testdata.AggregationTestCase{ ], "value": 211840 }, + "2": + { + "value": 212292 + }, "1-bucket": { "buckets": [ { @@ -2998,6 +3015,7 @@ var PipelineAggregationTests = []testdata.AggregationTestCase{ model.NewQueryResultCol("count()", 1), }}, }, + {}, // NoDBQuery }, ExpectedSQLs: []string{ `SELECT count() FROM ` + testdata.QuotedTableName, @@ -3010,6 +3028,7 @@ var PipelineAggregationTests = []testdata.AggregationTestCase{ `FROM ` + testdata.QuotedTableName + ` ` + `GROUP BY ("bytes") ` + `ORDER BY ("bytes")`, + `NoDBQuery`, }, }, /* waits for probably a simple filters fix @@ -3426,4 +3445,972 @@ var PipelineAggregationTests = []testdata.AggregationTestCase{ `FROM ` + testdata.QuotedTableName + ` `, }, }, */ + { // [19] + TestName: "Simplest sum_bucket. Reproduce: Visualize -> Horizontal Bar: Metrics: Sum Bucket (B ucket: Terms, Metric: Count)", + QueryRequestJson: ` + { + "_source": { + "excludes": [] + }, + "aggs": { + "1": { + "sum_bucket": { + "buckets_path": "1-bucket>_count" + } + }, + "1-bucket": { + "terms": { + "field": "extension.keyword", + "order": { + "_key": "desc" + }, + "size": 5 + } + } + }, + "docvalue_fields": [ + { + "field": "@timestamp", + "format": "date_time" + }, + { + "field": "timestamp", + "format": "date_time" + }, + { + "field": "utc_time", + "format": "date_time" + } + ], + "query": { + "bool": { + "filter": [ + { + "range": { + "timestamp": { + "format": "strict_date_optional_time", + "gte": "2024-04-27T22:16:26.906Z", + "lte": "2024-05-12T22:16:26.906Z" + } + } + } + ], + "must": [ + { + "match_all": {} + } + ], + "must_not": [], + "should": [] + } + }, + "script_fields": { + "hour_of_day": { + "script": { + "lang": "painless", + "source": "doc['timestamp'].value.getHour()" + } + } + }, + "size": 0, + "stored_fields": [ + "*" + ] + }`, + ExpectedResponse: ` + { + "_shards": { + "failed": 0, + "skipped": 0, + "successful": 1, + "total": 1 + }, + "aggregations": { + "1": { + "value": 1171.0 + }, + "1-bucket": { + "buckets": [ + { + "doc_count": 225, + "key": "zip" + }, + { + "doc_count": 76, + "key": "rpm" + }, + { + "doc_count": 348, + "key": "gz" + }, + { + "doc_count": 224, + "key": "deb" + }, + { + "doc_count": 298, + "key": "css" + } + ], + "doc_count_error_upper_bound": 0, + "sum_other_doc_count": 694 + } + }, + "hits": { + "hits": [], + "max_score": null, + "total": { + "relation": "eq", + "value": 1865 + } + }, + "timed_out": false, + "took": 45 + }`, + ExpectedResults: [][]model.QueryResultRow{ + {{Cols: []model.QueryResultCol{model.NewQueryResultCol("hits", uint64(202))}}}, + {}, // NoDBQuery + { + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol("key", "zip"), + model.NewQueryResultCol("doc_count", 225), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol("key", "rpm"), + model.NewQueryResultCol("doc_count", 76), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol("key", "gz"), + model.NewQueryResultCol("doc_count", 348), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol("key", "deb"), + model.NewQueryResultCol("doc_count", 224), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol("key", "css"), + model.NewQueryResultCol("doc_count", 298), + }}, + }, + }, + ExpectedSQLs: []string{ + `SELECT count() ` + + `FROM ` + testdata.QuotedTableName + ` ` + + `WHERE "timestamp"<=parseDateTime64BestEffort('2024-05-12T22:16:26.906Z') ` + + `AND "timestamp">=parseDateTime64BestEffort('2024-04-27T22:16:26.906Z')`, + `NoDBQuery`, + `SELECT "extension", count() ` + + `FROM ` + testdata.QuotedTableName + ` ` + + `WHERE "timestamp"<=parseDateTime64BestEffort('2024-05-12T22:16:26.906Z') ` + + `AND "timestamp">=parseDateTime64BestEffort('2024-04-27T22:16:26.906Z') ` + + `GROUP BY ("extension") ` + + `ORDER BY count() DESC ` + + `LIMIT 5`, + }, + }, + { // [20] + TestName: "sum_bucket. Reproduce: Visualize -> Horizontal Bar: Metrics: Sum Bucket (Bucket: Significant Terms, Metric: Average)", + QueryRequestJson: ` + { + "_source": { + "excludes": [] + }, + "aggs": { + "1": { + "sum_bucket": { + "buckets_path": "1-bucket>1-metric" + } + }, + "1-bucket": { + "aggs": { + "1-metric": { + "avg": { + "field": "machine.ram" + } + } + }, + "significant_terms": { + "field": "extension.keyword", + "size": 5 + } + } + }, + "docvalue_fields": [ + { + "field": "@timestamp", + "format": "date_time" + }, + { + "field": "timestamp", + "format": "date_time" + }, + { + "field": "utc_time", + "format": "date_time" + } + ], + "query": { + "bool": { + "filter": [], + "must": { + "match_all": {} + }, + "must_not": [], + "should": [] + } + }, + "script_fields": { + "hour_of_day": { + "script": { + "lang": "painless", + "source": "doc['timestamp'].value.getHour()" + } + } + }, + "size": 0, + "stored_fields": [ + "*" + ] + }`, + ExpectedResponse: ` + { + "_shards": { + "failed": 0, + "skipped": 0, + "successful": 1, + "total": 1 + }, + "aggregations": { + "1": { + "value": 37790724732.3343 + }, + "1-bucket": { + "bg_count": 14074, + "buckets": [ + { + "1-metric": { + "value": 12539770587.428572 + }, + "bg_count": 224, + "doc_count": 224, + "key": "deb", + "score": 224 + }, + { + "1-metric": { + "value": 12464949530.168888 + }, + "bg_count": 225, + "doc_count": 225, + "key": "zip", + "score": 225 + }, + { + "1-metric": { + "value": 12786004614.736841 + }, + "bg_count": 76, + "doc_count": 76, + "key": "rpm", + "score": 76 + } + ], + "doc_count": 1865 + } + }, + "hits": { + "hits": [], + "max_score": null, + "total": { + "relation": "eq", + "value": 1865 + } + }, + "timed_out": false, + "took": 54 + }`, + ExpectedResults: [][]model.QueryResultRow{ + {{Cols: []model.QueryResultCol{model.NewQueryResultCol("hits", uint64(1865))}}}, + {}, // NoDBQuery + { + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol("key", "deb"), + model.NewQueryResultCol("doc_count", 12539770587.428572), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol("key", "`zip`"), + model.NewQueryResultCol("doc_count", 12464949530.168888), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol("key", "rpm"), + model.NewQueryResultCol("doc_count", 12786004614.736841), + }}, + }, + { + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol("key", "deb"), + model.NewQueryResultCol("doc_count", 224), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol("key", "zip"), + model.NewQueryResultCol("doc_count", 225), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol("key", "rpm"), + model.NewQueryResultCol("doc_count", 76), + }}, + }, + }, + ExpectedSQLs: []string{ + `SELECT count() ` + + `FROM ` + testdata.QuotedTableName, + `NoDBQuery`, + `SELECT "extension", avgOrNull("machine.ram") ` + + `FROM ` + testdata.QuotedTableName + ` ` + + `GROUP BY ("extension") ` + + `ORDER BY ("extension")`, + `SELECT "extension", count() ` + + `FROM ` + testdata.QuotedTableName + ` ` + + `GROUP BY ("extension") ` + + `ORDER BY ("extension")`, + }, + }, + { // [21] + TestName: "complex sum_bucket. Reproduce: Visualize -> Vertical Bar: Metrics: Sum Bucket (Bucket: Date Histogram, Metric: Average), Buckets: X-Asis: Histogram", + QueryRequestJson: ` + { + "_source": { + "excludes": [] + }, + "aggs": { + "2": { + "aggs": { + "3": { + "aggs": { + "1": { + "sum_bucket": { + "buckets_path": "1-bucket>1-metric" + } + }, + "1-bucket": { + "aggs": { + "1-metric": { + "avg": { + "field": "memory" + } + } + }, + "date_histogram": { + "field": "timestamp", + "fixed_interval": "12h", + "min_doc_count": 1, + "time_zone": "Europe/Warsaw" + } + } + }, + "histogram": { + "field": "bytes", + "interval": 200, + "min_doc_count": 1 + } + } + }, + "range": { + "field": "bytes", + "keyed": true, + "ranges": [ + { + "from": 0, + "to": 1000 + }, + { + "from": 1000, + "to": 2000 + } + ] + } + } + }, + "docvalue_fields": [ + { + "field": "@timestamp", + "format": "date_time" + }, + { + "field": "timestamp", + "format": "date_time" + }, + { + "field": "utc_time", + "format": "date_time" + } + ], + "query": { + "bool": { + "filter": {}, + "must": [ + { + "match_all": {} + } + ], + "must_not": {} + } + }, + "script_fields": { + "hour_of_day": { + "script": { + "lang": "painless", + "source": "doc['timestamp'].value.getHour()" + } + } + }, + "size": 0, + "stored_fields": [ + "*" + ] + }`, + ExpectedResponse: ` + { + "_shards": { + "failed": 0, + "skipped": 0, + "successful": 1, + "total": 1 + }, + "aggregations": { + "2": { + "buckets": { + "0.0-1000.0": { + "3": { + "buckets": [ + { + "1": { + "value": 6920.0 + }, + "1-bucket": { + "buckets": [ + { + "1-metric": { + "value": null + }, + "doc_count": 6, + "key": 1714860000000, + "key_as_string": "2024-05-05T00:00:00.000+02:00" + }, + { + "1-metric": { + "value": 6920.0 + }, + "doc_count": 9, + "key": 1714903200000, + "key_as_string": "2024-05-05T12:00:00.000+02:00" + } + ] + }, + "doc_count": 15, + "key": 0.0 + }, + { + "1": { + "value": 22680.0 + }, + "1-bucket": { + "buckets": [ + { + "1-metric": { + "value": null + }, + "doc_count": 1, + "key": 1714860000000, + "key_as_string": "2024-05-05T00:00:00.000+02:00" + }, + { + "1-metric": { + "value": null + }, + "doc_count": 2, + "key": 1714989600000, + "key_as_string": "2024-05-06T12:00:00.000+02:00" + }, + { + "1-metric": { + "value": null + }, + "doc_count": 3, + "key": 1715076000000, + "key_as_string": "2024-05-07T12:00:00.000+02:00" + } + ] + }, + "doc_count": 6, + "key": 200.0 + }, + { + "1": { + "value": 82940.0 + }, + "1-bucket": { + "buckets": [ + { + "1-metric": { + "value": 27400.0 + }, + "doc_count": 1, + "key": 1714860000000, + "key_as_string": "2024-05-05T00:00:00.000+02:00" + } + ] + }, + "doc_count": 1, + "key": 600.0 + } + ] + }, + "doc_count": 168, + "from": 0.0, + "to": 1000.0 + }, + "1000.0-2000.0": { + "3": { + "buckets": [ + { + "1": { + "value": 87400.0 + }, + "1-bucket": { + "buckets": [ + { + "1-metric": { + "value": 43320.0 + }, + "doc_count": 1, + "key": 1715076000000, + "key_as_string": "2024-05-07T12:00:00.000+02:00" + }, + { + "1-metric": { + "value": 44080.0 + }, + "doc_count": 1, + "key": 1715205600000, + "key_as_string": "2024-05-09T00:00:00.000+02:00" + } + ] + }, + "doc_count": 2, + "key": 1000.0 + }, + { + "1": { + "value": 50040.0 + }, + "1-bucket": { + "buckets": [ + { + "1-metric": { + "value": 50040.0 + }, + "doc_count": 1, + "key": 1715162400000, + "key_as_string": "2024-05-08T12:00:00.000+02:00" + } + ] + }, + "doc_count": 1, + "key": 1200.0 + }, + { + "1": { + "value": 178320.0 + }, + "1-bucket": { + "buckets": [ + { + "1-metric": { + "value": null + }, + "doc_count": 1, + "key": 1714903200000, + "key_as_string": "2024-05-05T12:00:00.000+02:00" + }, + { + "1-metric": { + "value": null + }, + "doc_count": 2, + "key": 1715076000000, + "key_as_string": "2024-05-07T12:00:00.000+02:00" + } + ] + }, + "doc_count": 3, + "key": 1400.0 + }, + { + "1": { + "value": 135880.0 + }, + "1-bucket": { + "buckets": [ + { + "1-metric": { + "value": null + }, + "doc_count": 3, + "key": 1714860000000, + "key_as_string": "2024-05-05T00:00:00.000+02:00" + }, + { + "1-metric": { + "value": null + }, + "doc_count": 1, + "key": 1715248800000, + "key_as_string": "2024-05-09T12:00:00.000+02:00" + } + ] + }, + "doc_count": 4, + "key": 1600.0 + }, + { + "1": { + "value": 72640.0 + }, + "1-bucket": { + "buckets": [ + { + "1-metric": { + "value": null + }, + "doc_count": 2, + "key": 1714860000000, + "key_as_string": "2024-05-05T00:00:00.000+02:00" + }, + { + "1-metric": { + "value": 72640.0 + }, + "doc_count": 6, + "key": 1714903200000, + "key_as_string": "2024-05-05T12:00:00.000+02:00" + }, + { + "1-metric": { + "value": null + }, + "doc_count": 8, + "key": 1714989600000, + "key_as_string": "2024-05-06T12:00:00.000+02:00" + }, + { + "1-metric": { + "value": null + }, + "doc_count": 7, + "key": 1715076000000, + "key_as_string": "2024-05-07T12:00:00.000+02:00" + } + ] + }, + "doc_count": 23, + "key": 1800.0 + } + ] + }, + "doc_count": 94, + "from": 1000.0, + "to": 2000.0 + } + } + } + }, + "hits": { + "hits": [], + "max_score": null, + "total": { + "relation": "eq", + "value": 1865 + } + }, + "timed_out": false, + "took": 40 + }`, + ExpectedResults: [][]model.QueryResultRow{ + {{Cols: []model.QueryResultCol{model.NewQueryResultCol("hits", uint64(1865))}}}, + {}, // NoDBQuery + { + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 0.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714860000000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, nil), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 0.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714903200000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, 6920.0), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 200.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714860000000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, 1000.0), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 200.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714989600000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, nil), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 200.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715076000000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, nil), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 600.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714860000000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, 27400.0), + }}, + }, + { + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 0.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714860000000/43200000)), + model.NewQueryResultCol(`count()`, 6), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 0.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714903200000/43200000)), + model.NewQueryResultCol(`count()`, 9), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 200.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714860000000/43200000)), + model.NewQueryResultCol(`count()`, 1), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 200.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714989600000/43200000)), + model.NewQueryResultCol(`count()`, 2), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 200.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715076000000/43200000)), + model.NewQueryResultCol(`count()`, 3), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 600.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714860000000/43200000)), + model.NewQueryResultCol(`count()`, 1), + }}, + }, + { + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 0.0), + model.NewQueryResultCol(`count()`, 15), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 200.0), + model.NewQueryResultCol(`count()`, 6), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 600.0), + model.NewQueryResultCol(`count()`, 1), + }}, + }, + {}, // NoDBQuery + { + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1000.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715076000000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, 43320.0), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1000.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715205600000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, 44080.0), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1200.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715162400000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, 50040.0), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1400.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714903200000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, nil), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1400.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715076000000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, nil), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1600.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714860000000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, nil), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1600.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715248800000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, nil), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1800.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714860000000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, nil), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1800.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714903200000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, 72640.0), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1800.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714989600000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, nil), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1800.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715076000000/43200000)), + model.NewQueryResultCol(`avgOrNull("memory")`, nil), + }}, + }, + { + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1000.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715076000000/43200000)), + model.NewQueryResultCol(`count()`, 1), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1000.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715205600000/43200000)), + model.NewQueryResultCol(`count()`, 1), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1200.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715162400000/43200000)), + model.NewQueryResultCol(`count()`, 1), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1400.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714903200000/43200000)), + model.NewQueryResultCol(`count()`, 1), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1400.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715076000000/43200000)), + model.NewQueryResultCol(`count()`, 2), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1600.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714860000000/43200000)), + model.NewQueryResultCol(`count()`, 3), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1600.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715248800000/43200000)), + model.NewQueryResultCol(`count()`, 1), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1800.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714860000000/43200000)), + model.NewQueryResultCol(`count()`, 2), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1800.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714903200000/43200000)), + model.NewQueryResultCol(`count()`, 6), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1800.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1714989600000/43200000)), + model.NewQueryResultCol(`count()`, 8), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1800.0), + model.NewQueryResultCol("toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)", int64(1715076000000/43200000)), + model.NewQueryResultCol(`count()`, 7), + }}, + }, + { + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1000.0), + model.NewQueryResultCol(`count()`, 2), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1200.0), + model.NewQueryResultCol(`count()`, 1), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1400.0), + model.NewQueryResultCol(`count()`, 3), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1600.0), + model.NewQueryResultCol(`count()`, 4), + }}, + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`floor("bytes" / 200.000000) * 200.000000`, 1800.0), + model.NewQueryResultCol(`count()`, 23), + }}, + }, + { + {Cols: []model.QueryResultCol{ + model.NewQueryResultCol(`count(if("bytes">=0 AND "bytes"<1000, 1, NULL))`, 168), + model.NewQueryResultCol(`count(if("bytes">=1000 AND "bytes"<2000, 1, NULL))`, 94), + model.NewQueryResultCol(`count()`, 1865), + }}, + }, + }, + ExpectedSQLs: []string{ + `SELECT count() ` + + `FROM ` + testdata.QuotedTableName, + `NoDBQuery`, + `SELECT floor("bytes" / 200.000000) * 200.000000, ` + + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000), " + + `avgOrNull("memory") ` + + `FROM ` + testdata.QuotedTableName + ` ` + + `WHERE "bytes">=0 AND "bytes"<1000 ` + + `GROUP BY (floor("bytes" / 200.000000) * 200.000000, ` + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)) " + + `ORDER BY (floor("bytes" / 200.000000) * 200.000000, ` + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000))", + `SELECT floor("bytes" / 200.000000) * 200.000000, ` + + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000), " + + `count() ` + + `FROM ` + testdata.QuotedTableName + ` ` + + `WHERE "bytes">=0 AND "bytes"<1000 ` + + `GROUP BY (floor("bytes" / 200.000000) * 200.000000, ` + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)) " + + `ORDER BY (floor("bytes" / 200.000000) * 200.000000, ` + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000))", + `SELECT floor("bytes" / 200.000000) * 200.000000, ` + + `count() ` + + `FROM ` + testdata.QuotedTableName + ` ` + + `WHERE "bytes">=0 AND "bytes"<1000 ` + + `GROUP BY (floor("bytes" / 200.000000) * 200.000000) ` + + `ORDER BY (floor("bytes" / 200.000000) * 200.000000)`, + `NoDBQuery`, + `SELECT floor("bytes" / 200.000000) * 200.000000, ` + + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000), " + + `avgOrNull("memory") ` + + `FROM ` + testdata.QuotedTableName + ` ` + + `WHERE "bytes">=1000 AND "bytes"<2000 ` + + `GROUP BY (floor("bytes" / 200.000000) * 200.000000, ` + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)) " + + `ORDER BY (floor("bytes" / 200.000000) * 200.000000, ` + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000))", + `SELECT floor("bytes" / 200.000000) * 200.000000, ` + + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000), " + + `count() ` + + `FROM ` + testdata.QuotedTableName + ` ` + + `WHERE "bytes">=1000 AND "bytes"<2000 ` + + `GROUP BY (floor("bytes" / 200.000000) * 200.000000, ` + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000)) " + + `ORDER BY (floor("bytes" / 200.000000) * 200.000000, ` + "toInt64(toUnixTimestamp64Milli(`timestamp`)/43200000))", + `SELECT floor("bytes" / 200.000000) * 200.000000, ` + + `count() ` + + `FROM ` + testdata.QuotedTableName + ` ` + + `WHERE "bytes">=1000 AND "bytes"<2000 ` + + `GROUP BY (floor("bytes" / 200.000000) * 200.000000) ` + + `ORDER BY (floor("bytes" / 200.000000) * 200.000000)`, + `SELECT count(if("bytes">=0 AND "bytes"<1000, 1, NULL)), ` + + `count(if("bytes">=1000 AND "bytes"<2000, 1, NULL)), ` + + `count() ` + + `FROM ` + testdata.QuotedTableName, + }, + }, } diff --git a/quesma/testdata/unsupported_requests.go b/quesma/testdata/unsupported_requests.go index 7279a1a74..9e8bda599 100644 --- a/quesma/testdata/unsupported_requests.go +++ b/quesma/testdata/unsupported_requests.go @@ -1158,34 +1158,6 @@ var UnsupportedQueriesTests = []UnsupportedQueryTestCase{ } }`, }, - { // [56] - TestName: "pipeline aggregation: sum_bucket", - QueryType: "sum_bucket", - QueryRequestJson: ` - { - "size": 0, - "aggs": { - "sales_per_month": { - "date_histogram": { - "field": "date", - "calendar_interval": "month" - }, - "aggs": { - "sales": { - "sum": { - "field": "price" - } - } - } - }, - "sum_monthly_sales": { - "sum_bucket": { - "buckets_path": "sales_per_month>sales" - } - } - } - }`, - }, // random non-existing aggregation: { // [57] TestName: "non-existing aggregation: Augustus_Caesar",