fix(query/influxql): messed up a transpiler unit test

One of the transpiler unit tests got messed up during a recent PR. This
restores the unit test for conditionals.
pull/10616/head
Jonathan A. Sternberg 2018-06-13 09:47:03 -05:00
parent e900480bda
commit a1ccecd873
1 changed files with 25 additions and 119 deletions

View File

@ -729,7 +729,7 @@ func TestTranspiler(t *testing.T) {
},
},
{
s: `SELECT mean(value) FROM db0..cpu; SELECT max(value) FROM db0..cpu`,
s: `SELECT mean(value) FROM db0..cpu WHERE host = 'server01'`,
spec: &query.Spec{
Operations: []*query.Operation{
{
@ -782,6 +782,28 @@ func TestTranspiler(t *testing.T) {
},
},
},
{
ID: "filter1",
Spec: &functions.FilterOpSpec{
Fn: &semantic.FunctionExpression{
Params: []*semantic.FunctionParam{
{Key: &semantic.Identifier{Name: "r"}},
},
Body: &semantic.BinaryExpression{
Operator: ast.EqualOperator,
Left: &semantic.MemberExpression{
Object: &semantic.IdentifierExpression{
Name: "r",
},
Property: "host",
},
Right: &semantic.StringLiteral{
Value: "server01",
},
},
},
},
},
{
ID: "group0",
Spec: &functions.GroupOpSpec{
@ -845,131 +867,15 @@ func TestTranspiler(t *testing.T) {
Name: "0",
},
},
{
ID: "from1",
Spec: &functions.FromOpSpec{
Database: "db0",
},
},
{
ID: "range1",
Spec: &functions.RangeOpSpec{
Start: query.Time{Absolute: time.Unix(0, influxqllib.MinTime)},
Stop: query.Time{Absolute: time.Unix(0, influxqllib.MaxTime)},
},
},
{
ID: "filter1",
Spec: &functions.FilterOpSpec{
Fn: &semantic.FunctionExpression{
Params: []*semantic.FunctionParam{
{Key: &semantic.Identifier{Name: "r"}},
},
Body: &semantic.LogicalExpression{
Operator: ast.AndOperator,
Left: &semantic.BinaryExpression{
Operator: ast.EqualOperator,
Left: &semantic.MemberExpression{
Object: &semantic.IdentifierExpression{
Name: "r",
},
Property: "_measurement",
},
Right: &semantic.StringLiteral{
Value: "cpu",
},
},
Right: &semantic.BinaryExpression{
Operator: ast.EqualOperator,
Left: &semantic.MemberExpression{
Object: &semantic.IdentifierExpression{
Name: "r",
},
Property: "_field",
},
Right: &semantic.StringLiteral{
Value: "value",
},
},
},
},
},
},
{
ID: "group1",
Spec: &functions.GroupOpSpec{
By: []string{"_measurement"},
},
},
{
ID: "max0",
Spec: &functions.MaxOpSpec{
SelectorConfig: execute.SelectorConfig{
Column: execute.DefaultValueColLabel,
},
},
},
{
ID: "map1",
Spec: &functions.MapOpSpec{
Fn: &semantic.FunctionExpression{
Params: []*semantic.FunctionParam{{
Key: &semantic.Identifier{Name: "r"},
}},
Body: &semantic.ObjectExpression{
Properties: []*semantic.Property{
{
Key: &semantic.Identifier{Name: "time"},
Value: &semantic.MemberExpression{
Object: &semantic.IdentifierExpression{
Name: "r",
},
Property: "_time",
},
},
{
Key: &semantic.Identifier{Name: "_measurement"},
Value: &semantic.MemberExpression{
Object: &semantic.IdentifierExpression{
Name: "r",
},
Property: "_measurement",
},
},
{
Key: &semantic.Identifier{Name: "max"},
Value: &semantic.MemberExpression{
Object: &semantic.IdentifierExpression{
Name: "r",
},
Property: "_value",
},
},
},
},
},
},
},
{
ID: "yield1",
Spec: &functions.YieldOpSpec{
Name: "1",
},
},
},
Edges: []query.Edge{
{Parent: "from0", Child: "range0"},
{Parent: "range0", Child: "filter0"},
{Parent: "filter0", Child: "group0"},
{Parent: "filter0", Child: "filter1"},
{Parent: "filter1", Child: "group0"},
{Parent: "group0", Child: "mean0"},
{Parent: "mean0", Child: "map0"},
{Parent: "map0", Child: "yield0"},
{Parent: "from1", Child: "range1"},
{Parent: "range1", Child: "filter1"},
{Parent: "filter1", Child: "group1"},
{Parent: "group1", Child: "max0"},
{Parent: "max0", Child: "map1"},
{Parent: "map1", Child: "yield1"},
},
},
},