From 3986125ef2ca31bb710645582116dc3b5b54514e Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Fri, 29 Jan 2021 09:48:02 -0600 Subject: [PATCH 1/2] feat(query/stdlib): promote schema and fill optimizations from feature flags --- query/stdlib/influxdata/influxdb/rules.go | 43 ----------- .../stdlib/influxdata/influxdb/rules_test.go | 74 ------------------- 2 files changed, 117 deletions(-) diff --git a/query/stdlib/influxdata/influxdb/rules.go b/query/stdlib/influxdata/influxdb/rules.go index 6d1e1a1ff7e..ce00d2fde75 100644 --- a/query/stdlib/influxdata/influxdb/rules.go +++ b/query/stdlib/influxdata/influxdb/rules.go @@ -31,8 +31,6 @@ func init() { PushDownBareAggregateRule{}, GroupWindowAggregateTransposeRule{}, // PushDownGroupAggregateRule{}, - SwitchFillImplRule{}, - SwitchSchemaMutationImplRule{}, ) plan.RegisterLogicalRules( MergeFiltersRule{}, @@ -1064,47 +1062,6 @@ func canPushGroupedAggregate(ctx context.Context, pn plan.Node) bool { return false } -type SwitchFillImplRule struct{} - -func (SwitchFillImplRule) Name() string { - return "SwitchFillImplRule" -} - -func (SwitchFillImplRule) Pattern() plan.Pattern { - return plan.Pat(universe.FillKind, plan.Any()) -} - -func (r SwitchFillImplRule) Rewrite(ctx context.Context, pn plan.Node) (plan.Node, bool, error) { - if !feature.MemoryOptimizedFill().Enabled(ctx) { - spec := pn.ProcedureSpec().Copy() - universe.UseDeprecatedImpl(spec) - if err := pn.ReplaceSpec(spec); err != nil { - return nil, false, err - } - } - return pn, false, nil -} - -type SwitchSchemaMutationImplRule struct{} - -func (SwitchSchemaMutationImplRule) Name() string { - return "SwitchSchemaMutationImplRule" -} - -func (SwitchSchemaMutationImplRule) Pattern() plan.Pattern { - return plan.Pat(universe.SchemaMutationKind, plan.Any()) -} - -func (r SwitchSchemaMutationImplRule) Rewrite(ctx context.Context, pn plan.Node) (plan.Node, bool, error) { - spec, ok := pn.ProcedureSpec().(*universe.DualImplProcedureSpec) - if !ok || spec.UseDeprecated { - return pn, false, nil - } - - spec.UseDeprecated = !feature.MemoryOptimizedSchemaMutation().Enabled(ctx) - return pn, spec.UseDeprecated, nil -} - func asSchemaMutationProcedureSpec(spec plan.ProcedureSpec) *universe.SchemaMutationProcedureSpec { if s, ok := spec.(*universe.DualImplProcedureSpec); ok { spec = s.ProcedureSpec diff --git a/query/stdlib/influxdata/influxdb/rules_test.go b/query/stdlib/influxdata/influxdb/rules_test.go index 2de46fea315..a4634125ae0 100644 --- a/query/stdlib/influxdata/influxdb/rules_test.go +++ b/query/stdlib/influxdata/influxdb/rules_test.go @@ -2878,80 +2878,6 @@ func TestPushDownGroupAggregateRule(t *testing.T) { } } -func TestSwitchFillImplRule(t *testing.T) { - flagger := mock.NewFlagger(map[feature.Flag]interface{}{ - feature.MemoryOptimizedFill(): true, - }) - withFlagger, _ := feature.Annotate(context.Background(), flagger) - readRange := &influxdb.ReadRangePhysSpec{ - Bucket: "my-bucket", - Bounds: flux.Bounds{ - Start: fluxTime(5), - Stop: fluxTime(10), - }, - } - sourceSpec := &universe.DualImplProcedureSpec{ - ProcedureSpec: &universe.FillProcedureSpec{ - DefaultCost: plan.DefaultCost{}, - Column: "_value", - Value: values.NewFloat(0), - UsePrevious: false, - }, - UseDeprecated: false, - } - targetSpec := sourceSpec.Copy().(*universe.DualImplProcedureSpec) - universe.UseDeprecatedImpl(targetSpec) - - testcases := []plantest.RuleTestCase{ - { - Context: withFlagger, - Name: "enable memory optimized fill", - Rules: []plan.Rule{influxdb.SwitchFillImplRule{}}, - Before: &plantest.PlanSpec{ - Nodes: []plan.Node{ - plan.CreatePhysicalNode("ReadRange", readRange), - plan.CreatePhysicalNode("fill", sourceSpec), - }, - Edges: [][2]int{ - {0, 1}, - }, - }, - NoChange: true, - }, - { - Context: context.Background(), - Name: "disable memory optimized fill", - Rules: []plan.Rule{influxdb.SwitchFillImplRule{}}, - Before: &plantest.PlanSpec{ - Nodes: []plan.Node{ - plan.CreatePhysicalNode("ReadRange", readRange), - plan.CreatePhysicalNode("fill", sourceSpec), - }, - Edges: [][2]int{ - {0, 1}, - }, - }, - After: &plantest.PlanSpec{ - Nodes: []plan.Node{ - plan.CreatePhysicalNode("ReadRange", readRange), - plan.CreatePhysicalNode("fill", targetSpec), - }, - Edges: [][2]int{ - {0, 1}, - }, - }, - }, - } - - for _, tc := range testcases { - tc := tc - t.Run(tc.Name, func(t *testing.T) { - t.Parallel() - plantest.PhysicalRuleTestHelper(t, &tc) - }) - } -} - func TestMergeFilterRule(t *testing.T) { from := &fluxinfluxdb.FromProcedureSpec{} filter0 := func() *universe.FilterProcedureSpec { From 0a6184c6aaf93984feeb09463bd4aaefbb8340f4 Mon Sep 17 00:00:00 2001 From: Dan Moran Date: Fri, 29 Jan 2021 08:24:12 -0800 Subject: [PATCH 2/2] chore: update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 604d8611074..b66475a91b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ Replacement `tsi1` indexes will be automatically generated on startup for shards 1. [20591](https://github.com/influxdata/influxdb/pull/20591): Add `nats-port` config option for `influxd` server. 1. [20591](https://github.com/influxdata/influxdb/pull/20591): Add `nats-max-payload-bytes` config option for `influxd` server. 1. [20608](https://github.com/influxdata/influxdb/pull/20608): Add `influxd inspect export-lp` command to extract data in line-protocol format. +1. [20650](https://github.com/influxdata/influxdb/pull/20650): Promote schema and fill query optimizations to default behavior. ### Bug Fixes