Skip to content

Commit

Permalink
feat(query/stdlib): update push down window logic for location option
Browse files Browse the repository at this point in the history
  • Loading branch information
jsternberg committed Oct 1, 2021
1 parent 0a6f562 commit ffa567e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ require (
github.com/imdario/mergo v0.3.9 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/influxdata/cron v0.0.0-20201006132531-4bb0a200dcbe
github.com/influxdata/flux v0.132.0
github.com/influxdata/flux v0.132.1-0.20211001182920-09290bc83f0d
github.com/influxdata/httprouter v1.3.1-0.20191122104820-ee83e2772f69
github.com/influxdata/influx-cli/v2 v2.1.1-0.20210813175002-13799e7662c0
github.com/influxdata/influxdb-client-go/v2 v2.3.1-0.20210518120617-5d1fff431040 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/cron v0.0.0-20201006132531-4bb0a200dcbe h1:7j4SdN/BvQwN6WoUq7mv0kg5U9NhnFBxPGMafYRKym0=
github.com/influxdata/cron v0.0.0-20201006132531-4bb0a200dcbe/go.mod h1:XabtPPW2qsCg0tl+kjaPU+cFS+CjQXEXbT1VJvHT4og=
github.com/influxdata/flux v0.132.0 h1:9AFjm/2/yLDivEpXtYFL5Px/tL7Y5y2aVXa4py7Xbvk=
github.com/influxdata/flux v0.132.0/go.mod h1:RzogdNsdZoyDAw53BwLrhqyrVI7eT0IKEWW2UjAvTiw=
github.com/influxdata/flux v0.132.1-0.20211001182920-09290bc83f0d h1:tUyfM4ovhaVZBxFXfUfLXhTfOrqgwGrFEBLKevVmqyM=
github.com/influxdata/flux v0.132.1-0.20211001182920-09290bc83f0d/go.mod h1:RzogdNsdZoyDAw53BwLrhqyrVI7eT0IKEWW2UjAvTiw=
github.com/influxdata/httprouter v1.3.1-0.20191122104820-ee83e2772f69 h1:WQsmW0fXO4ZE/lFGIE84G6rIV5SJN3P3sjIXAP1a8eU=
github.com/influxdata/httprouter v1.3.1-0.20191122104820-ee83e2772f69/go.mod h1:pwymjR6SrP3gD3pRj9RJwdl1j5s3doEEV8gS4X9qSzA=
github.com/influxdata/influx-cli/v2 v2.1.1-0.20210813175002-13799e7662c0 h1:llPYnejbp/s9JkkS2xjSlAsdPKqIAsabhAgiOLV1NHw=
Expand Down
2 changes: 2 additions & 0 deletions query/stdlib/influxdata/influxdb/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ func isPushableWindow(windowSpec *universe.WindowProcedureSpec) bool {
// every and period must be equal
// every.isNegative must be false
// offset.isNegative must be false
// location must be "UTC"
// timeColumn: must be "_time"
// startColumn: must be "_start"
// stopColumn: must be "_stop"
Expand All @@ -724,6 +725,7 @@ func isPushableWindow(windowSpec *universe.WindowProcedureSpec) bool {
return window.Every.Equal(window.Period) &&
!window.Every.IsNegative() &&
!window.Offset.IsNegative() &&
window.Location == "UTC" &&
windowSpec.TimeColumn == "_time" &&
windowSpec.StartColumn == "_start" &&
windowSpec.StopColumn == "_stop"
Expand Down
33 changes: 21 additions & 12 deletions query/stdlib/influxdata/influxdb/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1181,9 +1181,10 @@ func TestPushDownWindowAggregateRule(t *testing.T) {
window := func(dur values.Duration) universe.WindowProcedureSpec {
return universe.WindowProcedureSpec{
Window: plan.WindowSpec{
Every: dur,
Period: dur,
Offset: dur0,
Every: dur,
Period: dur,
Offset: dur0,
Location: "UTC",
},
TimeColumn: "_time",
StartColumn: "_start",
Expand Down Expand Up @@ -1345,9 +1346,10 @@ func TestPushDownWindowAggregateRule(t *testing.T) {
Rules: []plan.Rule{influxdb.PushDownWindowAggregateRule{}},
Before: simplePlanWithWindowAgg(universe.WindowProcedureSpec{
Window: plan.WindowSpec{
Every: dur2m,
Period: dur2m,
Offset: dur1m,
Every: dur2m,
Period: dur2m,
Offset: dur1m,
Location: "UTC",
},
TimeColumn: "_time",
StartColumn: "_start",
Expand Down Expand Up @@ -2104,9 +2106,10 @@ func TestTransposeGroupToWindowAggregateRule(t *testing.T) {
window := func(dur values.Duration) universe.WindowProcedureSpec {
return universe.WindowProcedureSpec{
Window: plan.WindowSpec{
Every: dur,
Period: dur,
Offset: dur0,
Every: dur,
Period: dur,
Offset: dur0,
Location: "UTC",
},
TimeColumn: "_time",
StartColumn: "_start",
Expand Down Expand Up @@ -2332,9 +2335,10 @@ func TestTransposeGroupToWindowAggregateRule(t *testing.T) {
plan.CreateLogicalNode("group", group(flux.GroupModeBy, "host")),
plan.CreateLogicalNode("window", &universe.WindowProcedureSpec{
Window: plan.WindowSpec{
Every: dur2m,
Period: dur2m,
Offset: dur1m,
Every: dur2m,
Period: dur2m,
Offset: dur1m,
Location: "UTC",
},
TimeColumn: "_time",
StartColumn: "_start",
Expand Down Expand Up @@ -2411,6 +2415,11 @@ func TestTransposeGroupToWindowAggregateRule(t *testing.T) {
badWindow5.StopColumn = "_stappp"
simpleMinUnchanged("BadStop", badWindow5)

// Condition not met: non-UTC location
badWindow6 := window1m
badWindow6.Window.Location = "America/Los_Angeles"
simpleMinUnchanged("BadLocation", badWindow6)

// Condition met: createEmpty is true.
windowCreateEmpty1m := window1m
windowCreateEmpty1m.CreateEmpty = true
Expand Down

0 comments on commit ffa567e

Please sign in to comment.