Skip to content

Commit

Permalink
feat(storage): enable window agg mean pushdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Faith Chikwekwe committed Oct 22, 2020
1 parent 7947a7f commit 2273591
Show file tree
Hide file tree
Showing 9 changed files with 1,990 additions and 7 deletions.
46 changes: 44 additions & 2 deletions cmd/influxd/launcher/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package launcher_test

import (
"bytes"
"context"
"errors"
"fmt"
"html/template"
Expand Down Expand Up @@ -949,13 +948,13 @@ error2","query plan",109,110
}

func TestQueryPushDowns(t *testing.T) {
t.Skip("Not supported yet")
testcases := []struct {
name string
data []string
query string
op string
want string
skip string
}{
{
name: "range last single point start time",
Expand All @@ -975,6 +974,7 @@ from(bucket: v.bucket)
,result,table,_start,_stop,_time,_value,_field,_measurement,tag
,,0,1970-01-01T00:00:00.000000001Z,1970-01-01T01:00:00Z,1970-01-01T00:00:00.000000001Z,1,f,m,a
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window last",
Expand Down Expand Up @@ -1014,6 +1014,7 @@ from(bucket: v.bucket)
,,3,1970-01-01T00:00:12Z,1970-01-01T00:00:15Z,1970-01-01T00:00:14Z,9,f,m0,k0
,,4,1970-01-01T00:00:15Z,1970-01-01T00:00:18Z,1970-01-01T00:00:15Z,5,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window offset last",
Expand Down Expand Up @@ -1052,6 +1053,7 @@ from(bucket: v.bucket)
,,2,1970-01-01T00:00:11Z,1970-01-01T00:00:14Z,1970-01-01T00:00:13Z,8,f,m0,k0
,,3,1970-01-01T00:00:14Z,1970-01-01T00:00:17Z,1970-01-01T00:00:15Z,5,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "bare last",
Expand Down Expand Up @@ -1086,6 +1088,7 @@ from(bucket: v.bucket)
,result,table,_start,_stop,_time,_value,_field,_measurement,k
,,0,1970-01-01T00:00:05Z,1970-01-01T00:00:20Z,1970-01-01T00:00:15Z,5,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window empty last",
Expand Down Expand Up @@ -1131,6 +1134,7 @@ from(bucket: v.bucket)
#default,_result,2,1970-01-01T01:00:00Z,1970-01-01T02:00:00Z,,,f,m0,k0
,result,table,_start,_stop,_time,_value,_field,_measurement,k
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window empty offset last",
Expand Down Expand Up @@ -1176,6 +1180,7 @@ from(bucket: v.bucket)
#default,_result,2,1970-01-01T01:00:00Z,1970-01-01T02:00:00Z,,,f,m0,k0
,result,table,_start,_stop,_time,_value,_field,_measurement,k
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window aggregate last",
Expand Down Expand Up @@ -1211,6 +1216,7 @@ from(bucket: v.bucket)
,,0,1969-12-31T23:59:59Z,1970-01-01T00:00:33Z,1970-01-01T00:00:10Z,6,f,m0,k0
,,0,1969-12-31T23:59:59Z,1970-01-01T00:00:33Z,1970-01-01T00:00:20Z,5,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window first",
Expand Down Expand Up @@ -1250,6 +1256,7 @@ from(bucket: v.bucket)
,,3,1970-01-01T00:00:12Z,1970-01-01T00:00:15Z,1970-01-01T00:00:12Z,5,f,m0,k0
,,4,1970-01-01T00:00:15Z,1970-01-01T00:00:18Z,1970-01-01T00:00:15Z,5,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window first string",
Expand All @@ -1275,6 +1282,7 @@ from(bucket: v.bucket)
,,0,1970-01-01T00:00:00Z,1970-01-01T00:00:05Z,1970-01-01T00:00:02Z,c,f,m,a
,,1,1970-01-01T00:00:05Z,1970-01-01T00:00:10Z,1970-01-01T00:00:07Z,h,f,m,a
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "bare first",
Expand Down Expand Up @@ -1309,6 +1317,7 @@ from(bucket: v.bucket)
,result,table,_start,_stop,_time,_value,_field,_measurement,k
,,0,1970-01-01T00:00:05Z,1970-01-01T00:00:20Z,1970-01-01T00:00:05Z,5,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window empty first",
Expand Down Expand Up @@ -1360,6 +1369,7 @@ from(bucket: v.bucket)
#default,_result,3,1970-01-01T00:00:01.5Z,1970-01-01T00:00:02Z,,,f,m0,k0
,_result,table,_start,_stop,_time,_value,_field,_measurement,k
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window aggregate first",
Expand Down Expand Up @@ -1395,6 +1405,7 @@ from(bucket: v.bucket)
,,0,1970-01-01T00:00:00Z,1970-01-01T00:00:02Z,1970-01-01T00:00:00.5Z,0,f,m0,k0
,,0,1970-01-01T00:00:00Z,1970-01-01T00:00:02Z,1970-01-01T00:00:01.5Z,1,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window min",
Expand Down Expand Up @@ -1434,6 +1445,7 @@ from(bucket: v.bucket)
,,3,1970-01-01T00:00:12Z,1970-01-01T00:00:15Z,1970-01-01T00:00:12Z,5,f,m0,k0
,,4,1970-01-01T00:00:15Z,1970-01-01T00:00:18Z,1970-01-01T00:00:15Z,5,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "bare min",
Expand Down Expand Up @@ -1468,6 +1480,7 @@ from(bucket: v.bucket)
,result,table,_start,_stop,_time,_value,_field,_measurement,k
,,0,1970-01-01T00:00:05Z,1970-01-01T00:00:20Z,1970-01-01T00:00:08Z,0,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window empty min",
Expand Down Expand Up @@ -1509,6 +1522,7 @@ from(bucket: v.bucket)
#default,_result,3,1970-01-01T00:00:09Z,1970-01-01T00:00:12Z,,,f,m0,k0
,_result,table,_start,_stop,_time,_value,_field,_measurement,k
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window aggregate min",
Expand All @@ -1534,6 +1548,7 @@ from(bucket: v.bucket)
,,0,1970-01-01T00:00:00Z,1970-01-01T00:00:12Z,1970-01-01T00:00:03Z,0,f,m0,k0
,,0,1970-01-01T00:00:00Z,1970-01-01T00:00:12Z,1970-01-01T00:00:09Z,0,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window max",
Expand Down Expand Up @@ -1573,6 +1588,7 @@ from(bucket: v.bucket)
,,3,1970-01-01T00:00:12Z,1970-01-01T00:00:15Z,1970-01-01T00:00:14Z,9,f,m0,k0
,,4,1970-01-01T00:00:15Z,1970-01-01T00:00:18Z,1970-01-01T00:00:15Z,5,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "bare max",
Expand Down Expand Up @@ -1607,6 +1623,7 @@ from(bucket: v.bucket)
,result,table,_start,_stop,_time,_value,_field,_measurement,k
,,0,1970-01-01T00:00:05Z,1970-01-01T00:00:20Z,1970-01-01T00:00:14Z,9,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window empty max",
Expand Down Expand Up @@ -1648,6 +1665,7 @@ from(bucket: v.bucket)
#default,_result,3,1970-01-01T00:00:09Z,1970-01-01T00:00:12Z,,,f,m0,k0
,_result,table,_start,_stop,_time,_value,_field,_measurement,k
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window aggregate max",
Expand All @@ -1673,6 +1691,7 @@ from(bucket: v.bucket)
,,0,1970-01-01T00:00:00Z,1970-01-01T00:00:12Z,1970-01-01T00:00:03Z,2,f,m0,k0
,,0,1970-01-01T00:00:00Z,1970-01-01T00:00:12Z,1970-01-01T00:00:09Z,6,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window count removes empty series",
Expand All @@ -1696,6 +1715,7 @@ from(bucket: v.bucket)
,_result,0,1970-01-01T00:00:01Z,1970-01-01T00:00:01.5Z,0,f,m,a
,_result,1,1970-01-01T00:00:01.5Z,1970-01-01T00:00:02Z,1,f,m,a
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "count",
Expand Down Expand Up @@ -1733,6 +1753,7 @@ from(bucket: v.bucket)
,,0,1970-01-01T00:00:10Z,5,f,m0,k0
,,0,1970-01-01T00:00:15Z,5,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window offset count",
Expand Down Expand Up @@ -1771,6 +1792,7 @@ from(bucket: v.bucket)
,,2,1970-01-01T00:00:07Z,1970-01-01T00:00:12Z,5,f,m0,k0
,,3,1970-01-01T00:00:12Z,1970-01-01T00:00:15Z,3,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "count with nulls",
Expand Down Expand Up @@ -1803,6 +1825,7 @@ from(bucket: v.bucket)
,,0,1970-01-01T00:00:10Z,0,f,m0,k0
,,0,1970-01-01T00:00:15Z,5,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "bare count",
Expand Down Expand Up @@ -1838,6 +1861,7 @@ from(bucket: v.bucket)
,result,table,_value,_field,_measurement,k
,,0,15,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window sum removes empty series",
Expand All @@ -1862,6 +1886,7 @@ from(bucket: v.bucket)
,_result,0,1970-01-01T00:00:01Z,1970-01-01T00:00:01.5Z,,f,m,a
,_result,1,1970-01-01T00:00:01.5Z,1970-01-01T00:00:02Z,3,f,m,a
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "sum",
Expand Down Expand Up @@ -1899,6 +1924,7 @@ from(bucket: v.bucket)
,,0,1970-01-01T00:00:10Z,22,f,m0,k0
,,0,1970-01-01T00:00:15Z,35,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "window offset sum",
Expand Down Expand Up @@ -1937,6 +1963,7 @@ from(bucket: v.bucket)
,,2,1970-01-01T00:00:07Z,1970-01-01T00:00:12Z,24,f,m0,k0
,,3,1970-01-01T00:00:12Z,1970-01-01T00:00:15Z,22,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "sum with nulls",
Expand Down Expand Up @@ -1969,6 +1996,7 @@ from(bucket: v.bucket)
,,0,1970-01-01T00:00:10Z,,f,m0,k0
,,0,1970-01-01T00:00:15Z,35,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "bare sum",
Expand Down Expand Up @@ -2004,6 +2032,7 @@ from(bucket: v.bucket)
,result,table,_value,_field,_measurement,k
,,0,67,f,m0,k0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "bare mean",
Expand Down Expand Up @@ -2179,6 +2208,7 @@ from(bucket: v.bucket)
,result,table,_time,_value
,,0,1970-01-01T00:00:00.00Z,0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "group none first",
Expand Down Expand Up @@ -2215,6 +2245,7 @@ from(bucket: v.bucket)
,result,table,_time,_value
,,0,1970-01-01T00:00:00.00Z,0
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "group last",
Expand Down Expand Up @@ -2251,6 +2282,7 @@ from(bucket: v.bucket)
,result,table,_time,_value
,,0,1970-01-01T00:00:15.00Z,5
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "group none last",
Expand Down Expand Up @@ -2287,6 +2319,7 @@ from(bucket: v.bucket)
,result,table,_time,_value
,,0,1970-01-01T00:00:15.00Z,5
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "count group none",
Expand Down Expand Up @@ -2323,6 +2356,7 @@ from(bucket: v.bucket)
,result,table,_value
,,0,15
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "count group",
Expand Down Expand Up @@ -2360,6 +2394,7 @@ from(bucket: v.bucket)
,,0,kk0,8
,,1,kk1,7
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "sum group none",
Expand Down Expand Up @@ -2396,6 +2431,7 @@ from(bucket: v.bucket)
,result,table,_value
,,0,67
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "sum group",
Expand Down Expand Up @@ -2433,6 +2469,7 @@ from(bucket: v.bucket)
,,0,kk0,32
,,1,kk1,35
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "min group",
Expand Down Expand Up @@ -2470,6 +2507,7 @@ from(bucket: v.bucket)
,,0,kk0,0
,,1,kk1,1
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
{
name: "max group",
Expand Down Expand Up @@ -2507,11 +2545,15 @@ from(bucket: v.bucket)
,,0,kk0,9
,,1,kk1,8
`,
skip: "https://github.com/influxdata/idpe/issues/8828",
},
}
for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
if tc.skip != "" {
t.Skip(tc.skip)
}
l := launcher.RunTestLauncherOrFail(t, ctx, mock.NewFlagger(map[feature.Flag]interface{}{
feature.PushDownWindowAggregateMean(): true,
feature.PushDownGroupAggregateMinMax(): true,
Expand Down
1 change: 1 addition & 0 deletions query/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ type ReadWindowAggregateSpec struct {
Aggregates []plan.ProcedureKind
CreateEmpty bool
TimeColumn string
Window execute.Window
}

func (spec *ReadWindowAggregateSpec) Name() string {
Expand Down
Loading

0 comments on commit 2273591

Please sign in to comment.