Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(query): planner rule to push down window and bare first() and la… #18534

Merged
merged 2 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions cmd/influxd/launcher/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ from(bucket: v.bucket)
},
{
name: "count group",
op: "readGroup(count)",
op: "readGroup(count)",
q: `
from(bucket: v.bucket)
|> range(start: 1970-01-01T00:00:00Z, stop: 1970-01-01T00:00:15Z)
Expand Down Expand Up @@ -994,7 +994,7 @@ from(bucket: v.bucket)
},
{
name: "sum group",
op: "readGroup(sum)",
op: "readGroup(sum)",
q: `
from(bucket: v.bucket)
|> range(start: 1970-01-01T00:00:00Z, stop: 1970-01-01T00:00:15Z)
Expand Down
30 changes: 27 additions & 3 deletions flags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,33 @@
default: false
contact: Query Team

- name: Push Down Window Aggregate Rest
description: Enable non-Count, non-Sum variants of PushDownWindowAggregateRule and PushDownWindowAggregateRule (stage 2)
key: pushDownWindowAggregateRest
- name: Push Down Window Aggregate Min
ethanyzhang marked this conversation as resolved.
Show resolved Hide resolved
description: Enable Min variant of PushDownWindowAggregateRule and PushDownBareAggregateRule
key: pushDownWindowAggregateMin
default: false
contact: Query Team

- name: Push Down Window Aggregate Max
description: Enable Max variant of PushDownWindowAggregateRule and PushDownBareAggregateRule
key: pushDownWindowAggregateMax
default: false
contact: Query Team

- name: Push Down Window Aggregate Mean
description: Enable Mean variant of PushDownWindowAggregateRule and PushDownBareAggregateRule
key: pushDownWindowAggregateMean
default: false
contact: Query Team

- name: Push Down Window Aggregate First
description: Enable First variant of PushDownWindowAggregateRule and PushDownBareAggregateRule
key: pushDownWindowAggregateFirst
default: false
contact: Query Team

- name: Push Down Window Aggregate Last
description: Enable Last variant of PushDownWindowAggregateRule and PushDownBareAggregateRule
key: pushDownWindowAggregateLast
default: false
contact: Query Team

Expand Down
80 changes: 72 additions & 8 deletions kit/feature/list.go

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

25 changes: 15 additions & 10 deletions query/stdlib/influxdata/influxdb/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,11 +659,13 @@ func (PushDownWindowAggregateRule) Name() string {
}

var windowPushableAggs = []plan.ProcedureKind{
universe.CountKind,
universe.SumKind,
universe.MinKind,
universe.MaxKind,
universe.MeanKind,
universe.CountKind,
universe.SumKind,
universe.FirstKind,
universe.LastKind,
}

func (rule PushDownWindowAggregateRule) Pattern() plan.Pattern {
Expand All @@ -687,28 +689,25 @@ func canPushWindowedAggregate(ctx context.Context, fnNode plan.Node) bool {
// and check the feature flag associated with the aggregate function.
switch fnNode.Kind() {
case universe.MinKind:
if !feature.PushDownWindowAggregateRest().Enabled(ctx) || !caps.HaveMin() {
if !feature.PushDownWindowAggregateMin().Enabled(ctx) || !caps.HaveMin() {
return false
}

minSpec := fnNode.ProcedureSpec().(*universe.MinProcedureSpec)
if minSpec.Column != execute.DefaultValueColLabel {
return false
}
case universe.MaxKind:
if !feature.PushDownWindowAggregateRest().Enabled(ctx) || !caps.HaveMax() {
if !feature.PushDownWindowAggregateMax().Enabled(ctx) || !caps.HaveMax() {
return false
}

maxSpec := fnNode.ProcedureSpec().(*universe.MaxProcedureSpec)
if maxSpec.Column != execute.DefaultValueColLabel {
return false
}
case universe.MeanKind:
if !feature.PushDownWindowAggregateRest().Enabled(ctx) || !caps.HaveMean() {
if !feature.PushDownWindowAggregateMean().Enabled(ctx) || !caps.HaveMean() {
return false
}

meanSpec := fnNode.ProcedureSpec().(*universe.MeanProcedureSpec)
if len(meanSpec.Columns) != 1 || meanSpec.Columns[0] != execute.DefaultValueColLabel {
return false
Expand All @@ -717,7 +716,6 @@ func canPushWindowedAggregate(ctx context.Context, fnNode plan.Node) bool {
if !feature.PushDownWindowAggregateCount().Enabled(ctx) || !caps.HaveCount() {
return false
}

countSpec := fnNode.ProcedureSpec().(*universe.CountProcedureSpec)
if len(countSpec.Columns) != 1 || countSpec.Columns[0] != execute.DefaultValueColLabel {
return false
Expand All @@ -726,11 +724,18 @@ func canPushWindowedAggregate(ctx context.Context, fnNode plan.Node) bool {
if !feature.PushDownWindowAggregateSum().Enabled(ctx) || !caps.HaveSum() {
return false
}

sumSpec := fnNode.ProcedureSpec().(*universe.SumProcedureSpec)
if len(sumSpec.Columns) != 1 || sumSpec.Columns[0] != execute.DefaultValueColLabel {
return false
}
case universe.FirstKind:
if !feature.PushDownWindowAggregateFirst().Enabled(ctx) || !caps.HaveFirst() {
return false
}
case universe.LastKind:
if !feature.PushDownWindowAggregateLast().Enabled(ctx) || !caps.HaveLast() {
return false
}
}
return true
}
Expand Down
Loading