Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions engine/distributed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ func TestDistributedAggregations(t *testing.T) {
{name: "absent for existing metric with aggregation", query: `sum(absent(foo))`},
{name: "absent for existing metric", query: `absent(bar{pod="nginx-1"})`},
{name: "absent for existing metric with aggregation", query: `sum(absent(bar{pod="nginx-1"}))`},
{name: "subquery with sum/count", query: `max_over_time((sum(bar)/count(bar))[30s:15s])`},
{name: "subquery with avg", query: `max_over_time(avg(bar)[30s:15s])`},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test fails on main.

{name: "subquery with window within engine range", query: `max_over_time(sum_over_time(bar[30s])[30s:15s])`},
{name: "subquery with window outside of engine range", query: `max_over_time(sum_over_time(bar[1m])[10m:1m])`},
{name: "subquery with misaligned ranges", rangeStart: time.Unix(7, 0), query: `max_over_time(sum(bar)[30s:15s])`},
Expand Down
13 changes: 6 additions & 7 deletions logicalplan/distribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,6 @@ func (m DistributedExecutionOptimizer) Optimize(plan Node, opts *query.Options)
}
minEngineOverlap := labelRanges.minOverlap()

// TODO(fpetkovski): Consider changing TraverseBottomUp to pass in a list of parents in the transform function.
parents := make(map[*Node]*Node)
TraverseBottomUp(nil, &plan, func(parent, current *Node) (stop bool) {
parents[current] = parent
return false
})

// Preprocess rewrite distributable averages as sum/count
var warns = annotations.New()
TraverseBottomUp(nil, &plan, func(parent, current *Node) (stop bool) {
Expand Down Expand Up @@ -217,6 +210,12 @@ func (m DistributedExecutionOptimizer) Optimize(plan Node, opts *query.Options)
return !(isDistributive(parent, m.SkipBinaryPushdown, engineLabels, warns) || isAvgAggregation(parent))
})

// TODO(fpetkovski): Consider changing TraverseBottomUp to pass in a list of parents in the transform function.
parents := make(map[*Node]*Node)
TraverseBottomUp(nil, &plan, func(parent, current *Node) (stop bool) {
parents[current] = parent
return false
})
TraverseBottomUp(nil, &plan, func(parent, current *Node) (stop bool) {
// If the current operation is not distributive, stop the traversal.
if !isDistributive(current, m.SkipBinaryPushdown, engineLabels, warns) {
Expand Down
Loading