Skip to content

Commit

Permalink
fix: make tagKeys and tagValues work for edge cases involving _field
Browse files Browse the repository at this point in the history
Fixes #19806
Fixes #19794
  • Loading branch information
Christopher Wolff committed Oct 29, 2020
1 parent f6a26ee commit fd69f95
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 134 deletions.
7 changes: 3 additions & 4 deletions cmd/influxd/upgrade/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ func TestConfigUpgrade(t *testing.T) {
}
}
func TestConfigUpgradeFileNotExists(t *testing.T) {
targetOtions := optionsV2{
}
targetOtions := optionsV2{}
configFile := "/there/is/no/such/path/influxdb.conf"

// try upgrade
Expand Down Expand Up @@ -314,7 +313,7 @@ bind-address = "127.0.0.1:8088"
max-version = "tls1.3"
`

var testConfigV1obsoleteArrays =`
var testConfigV1obsoleteArrays = `
reporting-disabled = true
[meta]
Expand Down Expand Up @@ -393,7 +392,7 @@ tls-cert = "/etc/ssl/influxdb.pem"
tls-key = ""
`

var testConfigV2obsoleteArrays =`reporting-disabled = true
var testConfigV2obsoleteArrays = `reporting-disabled = true
bolt-path = "/db/.influxdbv2/influxd.bolt"
engine-path = "/db/.influxdbv2/engine"
`
Expand Down
10 changes: 5 additions & 5 deletions kit/io/limited_read_closer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package io

import (
"bytes"
"errors"
"io"
"io/ioutil"
"testing"
"errors"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -34,7 +34,7 @@ func TestLimitedReadCloser_Happy(t *testing.T) {
func TestLimitedReadCloseWithErrorAndLimitExceeded(t *testing.T) {
b := &closer{
Reader: bytes.NewBufferString("howdy"),
err: errors.New("some error"),
err: errors.New("some error"),
}
rc := NewLimitedReadCloser(b, 3)

Expand All @@ -49,7 +49,7 @@ func TestLimitedReadCloseWithError(t *testing.T) {
closeErr := errors.New("some error")
b := &closer{
Reader: bytes.NewBufferString("howdy"),
err: closeErr,
err: closeErr,
}
rc := NewLimitedReadCloser(b, 10)

Expand All @@ -63,7 +63,7 @@ func TestMultipleCloseOnlyClosesOnce(t *testing.T) {
closeErr := errors.New("some error")
b := &closer{
Reader: bytes.NewBufferString("howdy"),
err: closeErr,
err: closeErr,
}
rc := NewLimitedReadCloser(b, 10)

Expand All @@ -77,7 +77,7 @@ func TestMultipleCloseOnlyClosesOnce(t *testing.T) {

type closer struct {
io.Reader
err error
err error
closeCount int
}

Expand Down
5 changes: 2 additions & 3 deletions query/stdlib/influxdata/influxdb/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ func init() {
PushDownRangeRule{},
PushDownFilterRule{},
PushDownGroupRule{},
// These rules can be re-enabled with https://github.com/influxdata/influxdb/issues/19561 is fixed
// PushDownReadTagKeysRule{},
// PushDownReadTagValuesRule{},
PushDownReadTagKeysRule{},
PushDownReadTagValuesRule{},
SortedPivotRule{},
PushDownWindowAggregateRule{},
PushDownWindowAggregateByTimeRule{},
Expand Down
6 changes: 1 addition & 5 deletions query/stdlib/testing/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ var FluxEndToEndSkipList = map[string]map[string]string{
"http": {
"http_endpoint": "need ability to test side effects in e2e tests: (https://github.com/influxdata/flux/issues/1723)",
},
"influxdata/influxdb/schema": {
"show_measurements": "flaky test (https://github.com/influxdata/influxdb/issues/15450)",
"show_tag_values": "flaky test (https://github.com/influxdata/influxdb/issues/15450)",
"show_tag_keys": "flaky test (https://github.com/influxdata/influxdb/issues/15450)",
},
"influxdata/influxdb/schema": {},
"influxdata/influxdb/monitor": {
"state_changes_big_any_to_any": "unbounded test",
"state_changes_big_info_to_ok": "unbounded test",
Expand Down
8 changes: 6 additions & 2 deletions storage/reads/influxql_predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,12 @@ func (v *hasRefs) Visit(node influxql.Node) influxql.Visitor {
return v
}

func HasFieldValueKey(expr influxql.Expr) bool {
refs := hasRefs{refs: []string{fieldRef}, found: make([]bool, 1)}
func ExprHasKey(expr influxql.Expr, key string) bool {
refs := hasRefs{refs: []string{key}, found: make([]bool, 1)}
influxql.Walk(&refs, expr)
return refs.found[0]
}

func HasFieldValueKey(expr influxql.Expr) bool {
return ExprHasKey(expr, fieldRef)
}
5 changes: 2 additions & 3 deletions storage/reads/resultset.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"

"github.com/influxdata/influxdb/v2/models"
"github.com/influxdata/influxdb/v2/storage/reads/datatypes"
"github.com/influxdata/influxdb/v2/tsdb/cursors"
)

Expand All @@ -19,11 +18,11 @@ type resultSet struct {
arrayCursors multiShardCursors
}

func NewFilteredResultSet(ctx context.Context, req *datatypes.ReadFilterRequest, seriesCursor SeriesCursor) ResultSet {
func NewFilteredResultSet(ctx context.Context, start, end int64, seriesCursor SeriesCursor) ResultSet {
return &resultSet{
ctx: ctx,
seriesCursor: seriesCursor,
arrayCursors: newMultiShardArrayCursors(ctx, req.Range.Start, req.Range.End, true),
arrayCursors: newMultiShardArrayCursors(ctx, start, end, true),
}
}

Expand Down
24 changes: 24 additions & 0 deletions v1/services/storage/predicate_influxql.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,27 @@ func HasFieldKeyOrValue(expr influxql.Expr) (bool, bool) {
influxql.Walk(&refs, expr)
return refs.found[0], refs.found[1]
}

type hasAnyTagKeys struct {
found bool
}

func (v *hasAnyTagKeys) Visit(node influxql.Node) influxql.Visitor {
if v.found {
return nil
}

if n, ok := node.(*influxql.VarRef); ok {
if n.Val != fieldKey && n.Val != measurementKey && n.Val != "$" {
v.found = true
return nil
}
}
return v
}

func hasTagKey(expr influxql.Expr) bool {
v := &hasAnyTagKeys{}
influxql.Walk(v, expr)
return v.found
}
Loading

0 comments on commit fd69f95

Please sign in to comment.