From 87f88ebb67005955f34ee33b3f0e33276225aecc Mon Sep 17 00:00:00 2001 From: Yiqun Zhang Date: Sun, 1 Nov 2020 21:32:14 -0600 Subject: [PATCH 1/5] feat: add CreateUniquePhysicalNode --- execute/profiler.go | 14 +++++++++----- execute/profiler_test.go | 3 ++- internal/spec/build.go | 15 +++++++++++---- lang/compiler.go | 2 ++ plan/physical.go | 12 ++++++++++++ 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/execute/profiler.go b/execute/profiler.go index 74f2754d65..df3db2bc85 100644 --- a/execute/profiler.go +++ b/execute/profiler.go @@ -402,21 +402,25 @@ func (s *QueryProfiler) getTableBuilder(q flux.Query, alloc *memory.Allocator) ( stats.TotalAllocated, strings.Join(stats.RuntimeErrors, "\n"), } - stats.Metadata.Range(func(key string, value interface{}) bool { + for key, values := range stats.Metadata { var ty flux.ColType - if intValue, ok := value.(int); ok { + if intValue, ok := values[0].(int); ok { ty = flux.TInt colData = append(colData, int64(intValue)) } else { ty = flux.TString - colData = append(colData, fmt.Sprintf("%v", value)) + var data string + for _, value := range values { + valueStr := fmt.Sprintf("%v", value) + data += valueStr + "\n" + } + colData = append(colData, data) } colMeta = append(colMeta, flux.ColMeta{ Label: key, Type: ty, }) - return true - }) + } for _, col := range colMeta { if _, err := b.AddCol(col); err != nil { return nil, err diff --git a/execute/profiler_test.go b/execute/profiler_test.go index acc3dfb4b5..968bcdb48a 100644 --- a/execute/profiler_test.go +++ b/execute/profiler_test.go @@ -123,7 +123,8 @@ func TestQueryProfiler_GetResult(t *testing.T) { #default,_profiler,,,,,,,,,,,,,,, ,result,table,_measurement,TotalDuration,CompileDuration,QueueDuration,PlanDuration,RequeueDuration,ExecuteDuration,Concurrency,MaxAllocated,TotalAllocated,RuntimeErrors,flux/query-plan,influxdb/scanned-bytes,influxdb/scanned-values ,,0,profiler/query,1,2,3,4,5,6,7,8,9,"1 -2","query plan",10,11 +2","query plan +",10,11 ` q.Done() tbl, err := p.GetResult(q, &memory.Allocator{}) diff --git a/internal/spec/build.go b/internal/spec/build.go index c9e89db2a2..666d9df92a 100644 --- a/internal/spec/build.go +++ b/internal/spec/build.go @@ -10,17 +10,18 @@ import ( "github.com/influxdata/flux/execute" "github.com/influxdata/flux/internal/errors" "github.com/influxdata/flux/interpreter" + "github.com/influxdata/flux/plan" "github.com/opentracing/opentracing-go" ) type ider struct { - id int + id *int lookup map[*flux.TableObject]flux.OperationID } func (i *ider) nextID() int { - next := i.id - i.id++ + next := *i.id + *i.id++ return next } @@ -44,8 +45,14 @@ func (i *ider) ID(t *flux.TableObject) flux.OperationID { } func FromEvaluation(ctx context.Context, ses []interpreter.SideEffect, now time.Time) (*flux.Spec, error) { + var nextNodeID *int + if value := ctx.Value(plan.NextPlanNodeIDKey); value != nil { + nextNodeID = value.(*int) + } else { + nextNodeID = new(int) + } ider := &ider{ - id: 0, + id: nextNodeID, lookup: make(map[*flux.TableObject]flux.OperationID), } diff --git a/lang/compiler.go b/lang/compiler.go index 21e17dcc22..69a604064f 100644 --- a/lang/compiler.go +++ b/lang/compiler.go @@ -457,6 +457,8 @@ func (p *AstProgram) Start(ctx context.Context, alloc *memory.Allocator) (flux.Q // function calls during the evaluation phase (see `tableFind`). deps := execute.NewExecutionDependencies(alloc, &p.Now, p.Logger) ctx = deps.Inject(ctx) + nextPlanNodeID := new(int) + ctx = context.WithValue(ctx, plan.NextPlanNodeIDKey, nextPlanNodeID) // Evaluation. sp, scope, err := p.getSpec(ctx, alloc) diff --git a/plan/physical.go b/plan/physical.go index 76031e2282..f5c0586a5c 100644 --- a/plan/physical.go +++ b/plan/physical.go @@ -273,6 +273,18 @@ func CreatePhysicalNode(id NodeID, spec PhysicalProcedureSpec) *PhysicalPlanNode } } +const NextPlanNodeIDKey = "NextPlanNodeID" + +func CreateUniquePhysicalNode(ctx context.Context, prefix string, spec PhysicalProcedureSpec) *PhysicalPlanNode { + if value := ctx.Value(NextPlanNodeIDKey); value != nil { + nextNodeID := value.(*int) + id := NodeID(fmt.Sprintf("%s%d", prefix, *nextNodeID)) + *nextNodeID++ + return CreatePhysicalNode(id, spec) + } + return CreatePhysicalNode(NodeID(prefix), spec) +} + // PostPhysicalValidator provides an interface that can be implemented by PhysicalProcedureSpecs for any // validation checks to be performed post-physical planning. type PostPhysicalValidator interface { From 1c91300ecca3f3e3c897e1ddc36a47a6907014b6 Mon Sep 17 00:00:00 2001 From: Yiqun Zhang Date: Sun, 1 Nov 2020 23:31:29 -0600 Subject: [PATCH 2/5] feat: update rules in flux to use CreateUniquePhysicalNode --- stdlib/influxdata/influxdb/rules.go | 4 +- stdlib/influxdata/influxdb/rules_test.go | 77 ++++++++++++++++++++++++ stdlib/influxdata/influxdb/v1/rules.go | 2 +- 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/stdlib/influxdata/influxdb/rules.go b/stdlib/influxdata/influxdb/rules.go index 4b268deab4..3c96506d1f 100644 --- a/stdlib/influxdata/influxdb/rules.go +++ b/stdlib/influxdata/influxdb/rules.go @@ -37,7 +37,7 @@ func (p FromRemoteRule) Rewrite(ctx context.Context, node plan.Node) (plan.Node, config.Token = *spec.Token } - return plan.CreatePhysicalNode("fromRemote", &FromRemoteProcedureSpec{ + return plan.CreateUniquePhysicalNode(ctx, "fromRemote", &FromRemoteProcedureSpec{ Config: config, }), true, nil } @@ -127,7 +127,7 @@ func (p BucketsRemoteRule) Rewrite(ctx context.Context, node plan.Node) (plan.No return node, false, nil } - return plan.CreatePhysicalNode("bucketsRemote", &BucketsRemoteProcedureSpec{ + return plan.CreateUniquePhysicalNode(ctx, "bucketsRemote", &BucketsRemoteProcedureSpec{ BucketsProcedureSpec: spec, }), true, nil } diff --git a/stdlib/influxdata/influxdb/rules_test.go b/stdlib/influxdata/influxdb/rules_test.go index d5b9ccaa03..ea287cdae8 100644 --- a/stdlib/influxdata/influxdb/rules_test.go +++ b/stdlib/influxdata/influxdb/rules_test.go @@ -18,6 +18,83 @@ import ( "github.com/influxdata/flux/values/valuestest" ) +func TestRuleCreatedNodeUniqueness(t *testing.T) { + nextPlanNodeID := 3 + ctx := context.WithValue(context.Background(), plan.NextPlanNodeIDKey, &nextPlanNodeID) + host, token := "localhost", "token" + bucketsProcedureSpec := &influxdb.BucketsProcedureSpec{ + Org: &influxdb.NameOrID{Name: "influxdata"}, + Host: &host, + Token: &token, + } + joinSpec := &universe.MergeJoinProcedureSpec{ + TableNames: []string{"a", "b"}, + On: []string{"_value"}, + } + fromSpec := &influxdb.FromProcedureSpec{ + Bucket: influxdb.NameOrID{Name: "my-bucket"}, + Host: &host, + } + fromRemoteSpec := &influxdb.FromRemoteProcedureSpec{ + Config: influxdb.Config{Bucket: influxdb.NameOrID{Name: "my-bucket"}, Host: "localhost"}, + } + joinEdges := [][2]int{{0, 2}, {1, 2}} + tcs := []plantest.RuleTestCase{ + { + Name: "BucketsRemoteJoin", + Context: ctx, + Rules: []plan.Rule{influxdb.BucketsRemoteRule{}}, + Before: &plantest.PlanSpec{ + Nodes: []plan.Node{ + plan.CreateLogicalNode("buckets0", bucketsProcedureSpec), + plan.CreateLogicalNode("buckets1", bucketsProcedureSpec), + plan.CreateLogicalNode("join2", joinSpec), + }, + Edges: joinEdges, + }, + After: &plantest.PlanSpec{ + Nodes: []plan.Node{ + plan.CreatePhysicalNode("bucketsRemote3", &influxdb.BucketsRemoteProcedureSpec{ + BucketsProcedureSpec: bucketsProcedureSpec, + }), + plan.CreatePhysicalNode("bucketsRemote4", &influxdb.BucketsRemoteProcedureSpec{ + BucketsProcedureSpec: bucketsProcedureSpec, + }), + plan.CreatePhysicalNode("join2", joinSpec), + }, + Edges: joinEdges, + }, + }, + { + Name: "FromRemoteTableJoin", + Context: ctx, + Rules: []plan.Rule{influxdb.FromRemoteRule{}}, + Before: &plantest.PlanSpec{ + Nodes: []plan.Node{ + plan.CreateLogicalNode("from0", fromSpec), + plan.CreateLogicalNode("from1", fromSpec), + plan.CreateLogicalNode("join2", joinSpec), + }, + Edges: joinEdges, + }, + After: &plantest.PlanSpec{ + Nodes: []plan.Node{ + plan.CreatePhysicalNode("fromRemote5", fromRemoteSpec), + plan.CreatePhysicalNode("fromRemote6", fromRemoteSpec), + plan.CreatePhysicalNode("join2", joinSpec), + }, + Edges: joinEdges, + }, + }, + } + + for _, tc := range tcs { + t.Run(tc.Name, func(t *testing.T) { + plantest.PhysicalRuleTestHelper(t, &tc) + }) + } +} + func TestFromRemoteRule_WithHost(t *testing.T) { fromSpec := influxdb.FromProcedureSpec{ Org: &influxdb.NameOrID{Name: "influxdata"}, diff --git a/stdlib/influxdata/influxdb/v1/rules.go b/stdlib/influxdata/influxdb/v1/rules.go index cc35514775..bf692f0a94 100644 --- a/stdlib/influxdata/influxdb/v1/rules.go +++ b/stdlib/influxdata/influxdb/v1/rules.go @@ -22,7 +22,7 @@ func (p DatabasesRemoteRule) Rewrite(ctx context.Context, node plan.Node) (plan. return node, false, nil } - return plan.CreatePhysicalNode("databasesRemote", &DatabasesRemoteProcedureSpec{ + return plan.CreateUniquePhysicalNode(ctx, "databasesRemote", &DatabasesRemoteProcedureSpec{ DatabasesProcedureSpec: spec, }), true, nil } From be32bbf4325df93286d0763f44fd14db33015d80 Mon Sep 17 00:00:00 2001 From: Yiqun Zhang Date: Mon, 2 Nov 2020 00:40:00 -0600 Subject: [PATCH 3/5] feat: add regression test --- libflux/go/libflux/buildinfo.gen.go | 1 + stdlib/universe/flux_test_gen.go | 4130 +++++++++++++++++ .../universe/join_two_same_sources_test.flux | 66 + 3 files changed, 4197 insertions(+) create mode 100644 stdlib/universe/join_two_same_sources_test.flux diff --git a/libflux/go/libflux/buildinfo.gen.go b/libflux/go/libflux/buildinfo.gen.go index 7cbae09b23..fc3284c5b8 100644 --- a/libflux/go/libflux/buildinfo.gen.go +++ b/libflux/go/libflux/buildinfo.gen.go @@ -423,6 +423,7 @@ var sourceHashes = map[string]string{ "stdlib/universe/join_agg_test.flux": "8ab6a33469a50645e41deaaa1f87c1e4c4180b5d79dd87b03d6b4b1012f8ade9", "stdlib/universe/join_missing_on_col_test.flux": "98f4ca3999b1379d3a35f836449232e3b664fe312e5485179be57e4cc64e6ef4", "stdlib/universe/join_test.flux": "bdbbc60918fb9b683d9975816a9a9c59e2d7d1436847696b01414d740beffec3", + "stdlib/universe/join_two_same_sources_test.flux": "0d598a25c72d00ea9b06b9bfbdf8ff790e8b6ffd3aacd267a483438727c0f9c5", "stdlib/universe/join_use_previous_test.flux": "81fcaa31ff9a9a2a06a35a9275daf73cef0434061e8e81cb8317ccae172f7378", "stdlib/universe/kama_test.flux": "c84bfe6689f42f8bba75b9e06a4b1cb8e441615266ad0d12201d9fff27e34994", "stdlib/universe/kama_v2_test.flux": "f9d073089fdfd51c2260167d5e30b05de67ee3e4d91bc5e4261ed1ca722dfbc6", diff --git a/stdlib/universe/flux_test_gen.go b/stdlib/universe/flux_test_gen.go index c60cfef7de..af3aac7024 100644 --- a/stdlib/universe/flux_test_gen.go +++ b/stdlib/universe/flux_test_gen.go @@ -120967,6 +120967,4136 @@ var FluxTestPackages = []*ast.Package{&ast.Package{ Name: "universe_test", }, }, + }, &ast.File{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 93, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "package universe_test\n\nimport \"testing\"\nimport \"experimental/array\"\n\ninData = array.from(rows: [\n {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }\n])\n\nget_input = () => (inData)\n\noutData = \"\n#group,false,false,false,false,false,false,true,true,true,true,false,false,false\n#datatype,string,long,string,string,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,long,long\n#default,_result,,,,,,,,,,,,\n,result,table,_field_d1,_field_d2,_measurement_d1,_measurement_d2,_start_d1,_start_d2,_stop_d1,_stop_d2,_time,_value_d1,_value_d2\n,,0,id,guild,command,command,2018-12-19T22:13:30Z,2018-12-19T22:13:30Z,2018-12-19T22:13:50Z,2018-12-19T22:13:50Z,2018-12-19T22:13:31Z,12,12\n,,0,id,guild,command,command,2018-12-19T22:13:30Z,2018-12-19T22:13:30Z,2018-12-19T22:13:50Z,2018-12-19T22:13:50Z,2018-12-19T22:13:41Z,23,23\n\"\n\nt_join_two_same_sources = (table=<-) => {\n data_1 = table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"id\")\n |> aggregateWindow(every: 1s, fn: last)\n\n data_2 = table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"guild\")\n |> aggregateWindow(every: 1s, fn: last)\n\n return join(tables: {d1: data_1, d2: data_2}, on: [\"_time\"])\n}\n\ntest _join_two_same_sources = () =>\n ({input: get_input(), want: testing.loadMem(csv: outData), fn: t_join_two_same_sources})", + Start: ast.Position{ + Column: 1, + Line: 1, + }, + }, + }, + Body: []ast.Statement{&ast.VariableAssignment{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 3, + Line: 38, + }, + File: "join_two_same_sources_test.flux", + Source: "inData = array.from(rows: [\n {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }\n])", + Start: ast.Position{ + Column: 1, + Line: 6, + }, + }, + }, + ID: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 7, + Line: 6, + }, + File: "join_two_same_sources_test.flux", + Source: "inData", + Start: ast.Position{ + Column: 1, + Line: 6, + }, + }, + }, + Name: "inData", + }, + Init: &ast.CallExpression{ + Arguments: []ast.Expression{&ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 2, + Line: 38, + }, + File: "join_two_same_sources_test.flux", + Source: "rows: [\n {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }\n]", + Start: ast.Position{ + Column: 21, + Line: 6, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 2, + Line: 38, + }, + File: "join_two_same_sources_test.flux", + Source: "rows: [\n {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }\n]", + Start: ast.Position{ + Column: 21, + Line: 6, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 25, + Line: 6, + }, + File: "join_two_same_sources_test.flux", + Source: "rows", + Start: ast.Position{ + Column: 21, + Line: 6, + }, + }, + }, + Name: "rows", + }, + Value: &ast.ArrayExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 2, + Line: 38, + }, + File: "join_two_same_sources_test.flux", + Source: "[\n {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }\n]", + Start: ast.Position{ + Column: 27, + Line: 6, + }, + }, + }, + Elements: []ast.Expression{&ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 6, + Line: 12, + }, + File: "join_two_same_sources_test.flux", + Source: "{\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }", + Start: ast.Position{ + Column: 5, + Line: 7, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 8, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement: \"command\"", + Start: ast.Position{ + Column: 9, + Line: 8, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 8, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement", + Start: ast.Position{ + Column: 9, + Line: 8, + }, + }, + }, + Name: "_measurement", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 8, + }, + File: "join_two_same_sources_test.flux", + Source: "\"command\"", + Start: ast.Position{ + Column: 23, + Line: 8, + }, + }, + }, + Value: "command", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 9, + }, + File: "join_two_same_sources_test.flux", + Source: "_field: \"id\"", + Start: ast.Position{ + Column: 9, + Line: 9, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 9, + }, + File: "join_two_same_sources_test.flux", + Source: "_field", + Start: ast.Position{ + Column: 9, + Line: 9, + }, + }, + }, + Name: "_field", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 9, + }, + File: "join_two_same_sources_test.flux", + Source: "\"id\"", + Start: ast.Position{ + Column: 17, + Line: 9, + }, + }, + }, + Value: "id", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 10, + }, + File: "join_two_same_sources_test.flux", + Source: "_time: 2018-12-19T22:13:30.005Z", + Start: ast.Position{ + Column: 9, + Line: 10, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 14, + Line: 10, + }, + File: "join_two_same_sources_test.flux", + Source: "_time", + Start: ast.Position{ + Column: 9, + Line: 10, + }, + }, + }, + Name: "_time", + }, + Value: &ast.DateTimeLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 10, + }, + File: "join_two_same_sources_test.flux", + Source: "2018-12-19T22:13:30.005Z", + Start: ast.Position{ + Column: 16, + Line: 10, + }, + }, + }, + Value: parser.MustParseTime("2018-12-19T22:13:30.005Z"), + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 11, + }, + File: "join_two_same_sources_test.flux", + Source: "_value: 12", + Start: ast.Position{ + Column: 9, + Line: 11, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 11, + }, + File: "join_two_same_sources_test.flux", + Source: "_value", + Start: ast.Position{ + Column: 9, + Line: 11, + }, + }, + }, + Name: "_value", + }, + Value: &ast.IntegerLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 11, + }, + File: "join_two_same_sources_test.flux", + Source: "12", + Start: ast.Position{ + Column: 17, + Line: 11, + }, + }, + }, + Value: int64(12), + }, + }}, + With: nil, + }, &ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 6, + Line: 17, + }, + File: "join_two_same_sources_test.flux", + Source: "{\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }", + Start: ast.Position{ + Column: 8, + Line: 12, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 13, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement: \"command\"", + Start: ast.Position{ + Column: 9, + Line: 13, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 13, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement", + Start: ast.Position{ + Column: 9, + Line: 13, + }, + }, + }, + Name: "_measurement", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 13, + }, + File: "join_two_same_sources_test.flux", + Source: "\"command\"", + Start: ast.Position{ + Column: 23, + Line: 13, + }, + }, + }, + Value: "command", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 14, + }, + File: "join_two_same_sources_test.flux", + Source: "_field: \"id\"", + Start: ast.Position{ + Column: 9, + Line: 14, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 14, + }, + File: "join_two_same_sources_test.flux", + Source: "_field", + Start: ast.Position{ + Column: 9, + Line: 14, + }, + }, + }, + Name: "_field", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 14, + }, + File: "join_two_same_sources_test.flux", + Source: "\"id\"", + Start: ast.Position{ + Column: 17, + Line: 14, + }, + }, + }, + Value: "id", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 15, + }, + File: "join_two_same_sources_test.flux", + Source: "_time: 2018-12-19T22:13:40.005Z", + Start: ast.Position{ + Column: 9, + Line: 15, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 14, + Line: 15, + }, + File: "join_two_same_sources_test.flux", + Source: "_time", + Start: ast.Position{ + Column: 9, + Line: 15, + }, + }, + }, + Name: "_time", + }, + Value: &ast.DateTimeLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 15, + }, + File: "join_two_same_sources_test.flux", + Source: "2018-12-19T22:13:40.005Z", + Start: ast.Position{ + Column: 16, + Line: 15, + }, + }, + }, + Value: parser.MustParseTime("2018-12-19T22:13:40.005Z"), + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 16, + }, + File: "join_two_same_sources_test.flux", + Source: "_value: 23", + Start: ast.Position{ + Column: 9, + Line: 16, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 16, + }, + File: "join_two_same_sources_test.flux", + Source: "_value", + Start: ast.Position{ + Column: 9, + Line: 16, + }, + }, + }, + Name: "_value", + }, + Value: &ast.IntegerLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 16, + }, + File: "join_two_same_sources_test.flux", + Source: "23", + Start: ast.Position{ + Column: 17, + Line: 16, + }, + }, + }, + Value: int64(23), + }, + }}, + With: nil, + }, &ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 6, + Line: 22, + }, + File: "join_two_same_sources_test.flux", + Source: "{\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }", + Start: ast.Position{ + Column: 8, + Line: 17, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 18, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement: \"command\"", + Start: ast.Position{ + Column: 9, + Line: 18, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 18, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement", + Start: ast.Position{ + Column: 9, + Line: 18, + }, + }, + }, + Name: "_measurement", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 18, + }, + File: "join_two_same_sources_test.flux", + Source: "\"command\"", + Start: ast.Position{ + Column: 23, + Line: 18, + }, + }, + }, + Value: "command", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 19, + }, + File: "join_two_same_sources_test.flux", + Source: "_field: \"id\"", + Start: ast.Position{ + Column: 9, + Line: 19, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 19, + }, + File: "join_two_same_sources_test.flux", + Source: "_field", + Start: ast.Position{ + Column: 9, + Line: 19, + }, + }, + }, + Name: "_field", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 19, + }, + File: "join_two_same_sources_test.flux", + Source: "\"id\"", + Start: ast.Position{ + Column: 17, + Line: 19, + }, + }, + }, + Value: "id", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 20, + }, + File: "join_two_same_sources_test.flux", + Source: "_time: 2018-12-19T22:13:50.005Z", + Start: ast.Position{ + Column: 9, + Line: 20, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 14, + Line: 20, + }, + File: "join_two_same_sources_test.flux", + Source: "_time", + Start: ast.Position{ + Column: 9, + Line: 20, + }, + }, + }, + Name: "_time", + }, + Value: &ast.DateTimeLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 20, + }, + File: "join_two_same_sources_test.flux", + Source: "2018-12-19T22:13:50.005Z", + Start: ast.Position{ + Column: 16, + Line: 20, + }, + }, + }, + Value: parser.MustParseTime("2018-12-19T22:13:50.005Z"), + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 21, + }, + File: "join_two_same_sources_test.flux", + Source: "_value: 34", + Start: ast.Position{ + Column: 9, + Line: 21, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 21, + }, + File: "join_two_same_sources_test.flux", + Source: "_value", + Start: ast.Position{ + Column: 9, + Line: 21, + }, + }, + }, + Name: "_value", + }, + Value: &ast.IntegerLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 21, + }, + File: "join_two_same_sources_test.flux", + Source: "34", + Start: ast.Position{ + Column: 17, + Line: 21, + }, + }, + }, + Value: int64(34), + }, + }}, + With: nil, + }, &ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 6, + Line: 27, + }, + File: "join_two_same_sources_test.flux", + Source: "{\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }", + Start: ast.Position{ + Column: 8, + Line: 22, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 23, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement: \"command\"", + Start: ast.Position{ + Column: 9, + Line: 23, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 23, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement", + Start: ast.Position{ + Column: 9, + Line: 23, + }, + }, + }, + Name: "_measurement", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 23, + }, + File: "join_two_same_sources_test.flux", + Source: "\"command\"", + Start: ast.Position{ + Column: 23, + Line: 23, + }, + }, + }, + Value: "command", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 24, + Line: 24, + }, + File: "join_two_same_sources_test.flux", + Source: "_field: \"guild\"", + Start: ast.Position{ + Column: 9, + Line: 24, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 24, + }, + File: "join_two_same_sources_test.flux", + Source: "_field", + Start: ast.Position{ + Column: 9, + Line: 24, + }, + }, + }, + Name: "_field", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 24, + Line: 24, + }, + File: "join_two_same_sources_test.flux", + Source: "\"guild\"", + Start: ast.Position{ + Column: 17, + Line: 24, + }, + }, + }, + Value: "guild", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 25, + }, + File: "join_two_same_sources_test.flux", + Source: "_time: 2018-12-19T22:13:30.005Z", + Start: ast.Position{ + Column: 9, + Line: 25, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 14, + Line: 25, + }, + File: "join_two_same_sources_test.flux", + Source: "_time", + Start: ast.Position{ + Column: 9, + Line: 25, + }, + }, + }, + Name: "_time", + }, + Value: &ast.DateTimeLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 25, + }, + File: "join_two_same_sources_test.flux", + Source: "2018-12-19T22:13:30.005Z", + Start: ast.Position{ + Column: 16, + Line: 25, + }, + }, + }, + Value: parser.MustParseTime("2018-12-19T22:13:30.005Z"), + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 26, + }, + File: "join_two_same_sources_test.flux", + Source: "_value: 12", + Start: ast.Position{ + Column: 9, + Line: 26, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 26, + }, + File: "join_two_same_sources_test.flux", + Source: "_value", + Start: ast.Position{ + Column: 9, + Line: 26, + }, + }, + }, + Name: "_value", + }, + Value: &ast.IntegerLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 26, + }, + File: "join_two_same_sources_test.flux", + Source: "12", + Start: ast.Position{ + Column: 17, + Line: 26, + }, + }, + }, + Value: int64(12), + }, + }}, + With: nil, + }, &ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 6, + Line: 32, + }, + File: "join_two_same_sources_test.flux", + Source: "{\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }", + Start: ast.Position{ + Column: 8, + Line: 27, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 28, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement: \"command\"", + Start: ast.Position{ + Column: 9, + Line: 28, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 28, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement", + Start: ast.Position{ + Column: 9, + Line: 28, + }, + }, + }, + Name: "_measurement", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 28, + }, + File: "join_two_same_sources_test.flux", + Source: "\"command\"", + Start: ast.Position{ + Column: 23, + Line: 28, + }, + }, + }, + Value: "command", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 24, + Line: 29, + }, + File: "join_two_same_sources_test.flux", + Source: "_field: \"guild\"", + Start: ast.Position{ + Column: 9, + Line: 29, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 29, + }, + File: "join_two_same_sources_test.flux", + Source: "_field", + Start: ast.Position{ + Column: 9, + Line: 29, + }, + }, + }, + Name: "_field", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 24, + Line: 29, + }, + File: "join_two_same_sources_test.flux", + Source: "\"guild\"", + Start: ast.Position{ + Column: 17, + Line: 29, + }, + }, + }, + Value: "guild", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 30, + }, + File: "join_two_same_sources_test.flux", + Source: "_time: 2018-12-19T22:13:40.005Z", + Start: ast.Position{ + Column: 9, + Line: 30, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 14, + Line: 30, + }, + File: "join_two_same_sources_test.flux", + Source: "_time", + Start: ast.Position{ + Column: 9, + Line: 30, + }, + }, + }, + Name: "_time", + }, + Value: &ast.DateTimeLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 30, + }, + File: "join_two_same_sources_test.flux", + Source: "2018-12-19T22:13:40.005Z", + Start: ast.Position{ + Column: 16, + Line: 30, + }, + }, + }, + Value: parser.MustParseTime("2018-12-19T22:13:40.005Z"), + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 31, + }, + File: "join_two_same_sources_test.flux", + Source: "_value: 23", + Start: ast.Position{ + Column: 9, + Line: 31, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 31, + }, + File: "join_two_same_sources_test.flux", + Source: "_value", + Start: ast.Position{ + Column: 9, + Line: 31, + }, + }, + }, + Name: "_value", + }, + Value: &ast.IntegerLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 31, + }, + File: "join_two_same_sources_test.flux", + Source: "23", + Start: ast.Position{ + Column: 17, + Line: 31, + }, + }, + }, + Value: int64(23), + }, + }}, + With: nil, + }, &ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 6, + Line: 37, + }, + File: "join_two_same_sources_test.flux", + Source: "{\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }", + Start: ast.Position{ + Column: 8, + Line: 32, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 33, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement: \"command\"", + Start: ast.Position{ + Column: 9, + Line: 33, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 33, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement", + Start: ast.Position{ + Column: 9, + Line: 33, + }, + }, + }, + Name: "_measurement", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 32, + Line: 33, + }, + File: "join_two_same_sources_test.flux", + Source: "\"command\"", + Start: ast.Position{ + Column: 23, + Line: 33, + }, + }, + }, + Value: "command", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 24, + Line: 34, + }, + File: "join_two_same_sources_test.flux", + Source: "_field: \"guild\"", + Start: ast.Position{ + Column: 9, + Line: 34, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 34, + }, + File: "join_two_same_sources_test.flux", + Source: "_field", + Start: ast.Position{ + Column: 9, + Line: 34, + }, + }, + }, + Name: "_field", + }, + Value: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 24, + Line: 34, + }, + File: "join_two_same_sources_test.flux", + Source: "\"guild\"", + Start: ast.Position{ + Column: 17, + Line: 34, + }, + }, + }, + Value: "guild", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 35, + }, + File: "join_two_same_sources_test.flux", + Source: "_time: 2018-12-19T22:13:50.005Z", + Start: ast.Position{ + Column: 9, + Line: 35, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 14, + Line: 35, + }, + File: "join_two_same_sources_test.flux", + Source: "_time", + Start: ast.Position{ + Column: 9, + Line: 35, + }, + }, + }, + Name: "_time", + }, + Value: &ast.DateTimeLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 35, + }, + File: "join_two_same_sources_test.flux", + Source: "2018-12-19T22:13:50.005Z", + Start: ast.Position{ + Column: 16, + Line: 35, + }, + }, + }, + Value: parser.MustParseTime("2018-12-19T22:13:50.005Z"), + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 36, + }, + File: "join_two_same_sources_test.flux", + Source: "_value: 34", + Start: ast.Position{ + Column: 9, + Line: 36, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 36, + }, + File: "join_two_same_sources_test.flux", + Source: "_value", + Start: ast.Position{ + Column: 9, + Line: 36, + }, + }, + }, + Name: "_value", + }, + Value: &ast.IntegerLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 36, + }, + File: "join_two_same_sources_test.flux", + Source: "34", + Start: ast.Position{ + Column: 17, + Line: 36, + }, + }, + }, + Value: int64(34), + }, + }}, + With: nil, + }}, + }, + }}, + With: nil, + }}, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 3, + Line: 38, + }, + File: "join_two_same_sources_test.flux", + Source: "array.from(rows: [\n {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"id\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:30.005Z,\n _value: 12,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:40.005Z,\n _value: 23,\n }, {\n _measurement: \"command\",\n _field: \"guild\",\n _time: 2018-12-19T22:13:50.005Z,\n _value: 34,\n }\n])", + Start: ast.Position{ + Column: 10, + Line: 6, + }, + }, + }, + Callee: &ast.MemberExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 20, + Line: 6, + }, + File: "join_two_same_sources_test.flux", + Source: "array.from", + Start: ast.Position{ + Column: 10, + Line: 6, + }, + }, + }, + Object: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 15, + Line: 6, + }, + File: "join_two_same_sources_test.flux", + Source: "array", + Start: ast.Position{ + Column: 10, + Line: 6, + }, + }, + }, + Name: "array", + }, + Property: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 20, + Line: 6, + }, + File: "join_two_same_sources_test.flux", + Source: "from", + Start: ast.Position{ + Column: 16, + Line: 6, + }, + }, + }, + Name: "from", + }, + }, + }, + }, &ast.VariableAssignment{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 27, + Line: 40, + }, + File: "join_two_same_sources_test.flux", + Source: "get_input = () => (inData)", + Start: ast.Position{ + Column: 1, + Line: 40, + }, + }, + }, + ID: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 10, + Line: 40, + }, + File: "join_two_same_sources_test.flux", + Source: "get_input", + Start: ast.Position{ + Column: 1, + Line: 40, + }, + }, + }, + Name: "get_input", + }, + Init: &ast.FunctionExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 27, + Line: 40, + }, + File: "join_two_same_sources_test.flux", + Source: "() => (inData)", + Start: ast.Position{ + Column: 13, + Line: 40, + }, + }, + }, + Body: &ast.ParenExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 27, + Line: 40, + }, + File: "join_two_same_sources_test.flux", + Source: "(inData)", + Start: ast.Position{ + Column: 19, + Line: 40, + }, + }, + }, + Expression: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 26, + Line: 40, + }, + File: "join_two_same_sources_test.flux", + Source: "inData", + Start: ast.Position{ + Column: 20, + Line: 40, + }, + }, + }, + Name: "inData", + }, + }, + Params: []*ast.Property{}, + }, + }, &ast.VariableAssignment{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 2, + Line: 49, + }, + File: "join_two_same_sources_test.flux", + Source: "outData = \"\n#group,false,false,false,false,false,false,true,true,true,true,false,false,false\n#datatype,string,long,string,string,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,long,long\n#default,_result,,,,,,,,,,,,\n,result,table,_field_d1,_field_d2,_measurement_d1,_measurement_d2,_start_d1,_start_d2,_stop_d1,_stop_d2,_time,_value_d1,_value_d2\n,,0,id,guild,command,command,2018-12-19T22:13:30Z,2018-12-19T22:13:30Z,2018-12-19T22:13:50Z,2018-12-19T22:13:50Z,2018-12-19T22:13:31Z,12,12\n,,0,id,guild,command,command,2018-12-19T22:13:30Z,2018-12-19T22:13:30Z,2018-12-19T22:13:50Z,2018-12-19T22:13:50Z,2018-12-19T22:13:41Z,23,23\n\"", + Start: ast.Position{ + Column: 1, + Line: 42, + }, + }, + }, + ID: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 8, + Line: 42, + }, + File: "join_two_same_sources_test.flux", + Source: "outData", + Start: ast.Position{ + Column: 1, + Line: 42, + }, + }, + }, + Name: "outData", + }, + Init: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 2, + Line: 49, + }, + File: "join_two_same_sources_test.flux", + Source: "\"\n#group,false,false,false,false,false,false,true,true,true,true,false,false,false\n#datatype,string,long,string,string,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,long,long\n#default,_result,,,,,,,,,,,,\n,result,table,_field_d1,_field_d2,_measurement_d1,_measurement_d2,_start_d1,_start_d2,_stop_d1,_stop_d2,_time,_value_d1,_value_d2\n,,0,id,guild,command,command,2018-12-19T22:13:30Z,2018-12-19T22:13:30Z,2018-12-19T22:13:50Z,2018-12-19T22:13:50Z,2018-12-19T22:13:31Z,12,12\n,,0,id,guild,command,command,2018-12-19T22:13:30Z,2018-12-19T22:13:30Z,2018-12-19T22:13:50Z,2018-12-19T22:13:50Z,2018-12-19T22:13:41Z,23,23\n\"", + Start: ast.Position{ + Column: 11, + Line: 42, + }, + }, + }, + Value: "\n#group,false,false,false,false,false,false,true,true,true,true,false,false,false\n#datatype,string,long,string,string,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,long,long\n#default,_result,,,,,,,,,,,,\n,result,table,_field_d1,_field_d2,_measurement_d1,_measurement_d2,_start_d1,_start_d2,_stop_d1,_stop_d2,_time,_value_d1,_value_d2\n,,0,id,guild,command,command,2018-12-19T22:13:30Z,2018-12-19T22:13:30Z,2018-12-19T22:13:50Z,2018-12-19T22:13:50Z,2018-12-19T22:13:31Z,12,12\n,,0,id,guild,command,command,2018-12-19T22:13:30Z,2018-12-19T22:13:30Z,2018-12-19T22:13:50Z,2018-12-19T22:13:50Z,2018-12-19T22:13:41Z,23,23\n", + }, + }, &ast.VariableAssignment{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 2, + Line: 63, + }, + File: "join_two_same_sources_test.flux", + Source: "t_join_two_same_sources = (table=<-) => {\n data_1 = table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"id\")\n |> aggregateWindow(every: 1s, fn: last)\n\n data_2 = table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"guild\")\n |> aggregateWindow(every: 1s, fn: last)\n\n return join(tables: {d1: data_1, d2: data_2}, on: [\"_time\"])\n}", + Start: ast.Position{ + Column: 1, + Line: 51, + }, + }, + }, + ID: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 24, + Line: 51, + }, + File: "join_two_same_sources_test.flux", + Source: "t_join_two_same_sources", + Start: ast.Position{ + Column: 1, + Line: 51, + }, + }, + }, + Name: "t_join_two_same_sources", + }, + Init: &ast.FunctionExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 2, + Line: 63, + }, + File: "join_two_same_sources_test.flux", + Source: "(table=<-) => {\n data_1 = table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"id\")\n |> aggregateWindow(every: 1s, fn: last)\n\n data_2 = table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"guild\")\n |> aggregateWindow(every: 1s, fn: last)\n\n return join(tables: {d1: data_1, d2: data_2}, on: [\"_time\"])\n}", + Start: ast.Position{ + Column: 27, + Line: 51, + }, + }, + }, + Body: &ast.Block{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 2, + Line: 63, + }, + File: "join_two_same_sources_test.flux", + Source: "{\n data_1 = table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"id\")\n |> aggregateWindow(every: 1s, fn: last)\n\n data_2 = table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"guild\")\n |> aggregateWindow(every: 1s, fn: last)\n\n return join(tables: {d1: data_1, d2: data_2}, on: [\"_time\"])\n}", + Start: ast.Position{ + Column: 41, + Line: 51, + }, + }, + }, + Body: []ast.Statement{&ast.VariableAssignment{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 48, + Line: 55, + }, + File: "join_two_same_sources_test.flux", + Source: "data_1 = table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"id\")\n |> aggregateWindow(every: 1s, fn: last)", + Start: ast.Position{ + Column: 5, + Line: 52, + }, + }, + }, + ID: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 11, + Line: 52, + }, + File: "join_two_same_sources_test.flux", + Source: "data_1", + Start: ast.Position{ + Column: 5, + Line: 52, + }, + }, + }, + Name: "data_1", + }, + Init: &ast.PipeExpression{ + Argument: &ast.PipeExpression{ + Argument: &ast.PipeExpression{ + Argument: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 52, + }, + File: "join_two_same_sources_test.flux", + Source: "table", + Start: ast.Position{ + Column: 14, + Line: 52, + }, + }, + }, + Name: "table", + }, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 74, + Line: 53, + }, + File: "join_two_same_sources_test.flux", + Source: "table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)", + Start: ast.Position{ + Column: 14, + Line: 52, + }, + }, + }, + Call: &ast.CallExpression{ + Arguments: []ast.Expression{&ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 73, + Line: 53, + }, + File: "join_two_same_sources_test.flux", + Source: "start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z", + Start: ast.Position{ + Column: 18, + Line: 53, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 45, + Line: 53, + }, + File: "join_two_same_sources_test.flux", + Source: "start: 2018-12-19T22:13:30Z", + Start: ast.Position{ + Column: 18, + Line: 53, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 23, + Line: 53, + }, + File: "join_two_same_sources_test.flux", + Source: "start", + Start: ast.Position{ + Column: 18, + Line: 53, + }, + }, + }, + Name: "start", + }, + Value: &ast.DateTimeLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 45, + Line: 53, + }, + File: "join_two_same_sources_test.flux", + Source: "2018-12-19T22:13:30Z", + Start: ast.Position{ + Column: 25, + Line: 53, + }, + }, + }, + Value: parser.MustParseTime("2018-12-19T22:13:30Z"), + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 73, + Line: 53, + }, + File: "join_two_same_sources_test.flux", + Source: "stop: 2018-12-19T22:13:50Z", + Start: ast.Position{ + Column: 47, + Line: 53, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 51, + Line: 53, + }, + File: "join_two_same_sources_test.flux", + Source: "stop", + Start: ast.Position{ + Column: 47, + Line: 53, + }, + }, + }, + Name: "stop", + }, + Value: &ast.DateTimeLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 73, + Line: 53, + }, + File: "join_two_same_sources_test.flux", + Source: "2018-12-19T22:13:50Z", + Start: ast.Position{ + Column: 53, + Line: 53, + }, + }, + }, + Value: parser.MustParseTime("2018-12-19T22:13:50Z"), + }, + }}, + With: nil, + }}, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 74, + Line: 53, + }, + File: "join_two_same_sources_test.flux", + Source: "range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)", + Start: ast.Position{ + Column: 12, + Line: 53, + }, + }, + }, + Callee: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 17, + Line: 53, + }, + File: "join_two_same_sources_test.flux", + Source: "range", + Start: ast.Position{ + Column: 12, + Line: 53, + }, + }, + }, + Name: "range", + }, + }, + }, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 79, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"id\")", + Start: ast.Position{ + Column: 14, + Line: 52, + }, + }, + }, + Call: &ast.CallExpression{ + Arguments: []ast.Expression{&ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 78, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "fn: (r) => r._measurement == \"command\" and r._field == \"id\"", + Start: ast.Position{ + Column: 19, + Line: 54, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 78, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "fn: (r) => r._measurement == \"command\" and r._field == \"id\"", + Start: ast.Position{ + Column: 19, + Line: 54, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "fn", + Start: ast.Position{ + Column: 19, + Line: 54, + }, + }, + }, + Name: "fn", + }, + Value: &ast.FunctionExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 78, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "(r) => r._measurement == \"command\" and r._field == \"id\"", + Start: ast.Position{ + Column: 23, + Line: 54, + }, + }, + }, + Body: &ast.LogicalExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 78, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "r._measurement == \"command\" and r._field == \"id\"", + Start: ast.Position{ + Column: 30, + Line: 54, + }, + }, + }, + Left: &ast.BinaryExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 57, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "r._measurement == \"command\"", + Start: ast.Position{ + Column: 30, + Line: 54, + }, + }, + }, + Left: &ast.MemberExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 44, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "r._measurement", + Start: ast.Position{ + Column: 30, + Line: 54, + }, + }, + }, + Object: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 31, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "r", + Start: ast.Position{ + Column: 30, + Line: 54, + }, + }, + }, + Name: "r", + }, + Property: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 44, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement", + Start: ast.Position{ + Column: 32, + Line: 54, + }, + }, + }, + Name: "_measurement", + }, + }, + Operator: 17, + Right: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 57, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "\"command\"", + Start: ast.Position{ + Column: 48, + Line: 54, + }, + }, + }, + Value: "command", + }, + }, + Operator: 1, + Right: &ast.BinaryExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 78, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "r._field == \"id\"", + Start: ast.Position{ + Column: 62, + Line: 54, + }, + }, + }, + Left: &ast.MemberExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 70, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "r._field", + Start: ast.Position{ + Column: 62, + Line: 54, + }, + }, + }, + Object: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 63, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "r", + Start: ast.Position{ + Column: 62, + Line: 54, + }, + }, + }, + Name: "r", + }, + Property: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 70, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "_field", + Start: ast.Position{ + Column: 64, + Line: 54, + }, + }, + }, + Name: "_field", + }, + }, + Operator: 17, + Right: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 78, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "\"id\"", + Start: ast.Position{ + Column: 74, + Line: 54, + }, + }, + }, + Value: "id", + }, + }, + }, + Params: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 25, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "r", + Start: ast.Position{ + Column: 24, + Line: 54, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 25, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "r", + Start: ast.Position{ + Column: 24, + Line: 54, + }, + }, + }, + Name: "r", + }, + Value: nil, + }}, + }, + }}, + With: nil, + }}, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 79, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "filter(fn: (r) => r._measurement == \"command\" and r._field == \"id\")", + Start: ast.Position{ + Column: 12, + Line: 54, + }, + }, + }, + Callee: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 18, + Line: 54, + }, + File: "join_two_same_sources_test.flux", + Source: "filter", + Start: ast.Position{ + Column: 12, + Line: 54, + }, + }, + }, + Name: "filter", + }, + }, + }, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 48, + Line: 55, + }, + File: "join_two_same_sources_test.flux", + Source: "table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"id\")\n |> aggregateWindow(every: 1s, fn: last)", + Start: ast.Position{ + Column: 14, + Line: 52, + }, + }, + }, + Call: &ast.CallExpression{ + Arguments: []ast.Expression{&ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 47, + Line: 55, + }, + File: "join_two_same_sources_test.flux", + Source: "every: 1s, fn: last", + Start: ast.Position{ + Column: 28, + Line: 55, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 37, + Line: 55, + }, + File: "join_two_same_sources_test.flux", + Source: "every: 1s", + Start: ast.Position{ + Column: 28, + Line: 55, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 33, + Line: 55, + }, + File: "join_two_same_sources_test.flux", + Source: "every", + Start: ast.Position{ + Column: 28, + Line: 55, + }, + }, + }, + Name: "every", + }, + Value: &ast.DurationLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 37, + Line: 55, + }, + File: "join_two_same_sources_test.flux", + Source: "1s", + Start: ast.Position{ + Column: 35, + Line: 55, + }, + }, + }, + Values: []ast.Duration{ast.Duration{ + Magnitude: int64(1), + Unit: "s", + }}, + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 47, + Line: 55, + }, + File: "join_two_same_sources_test.flux", + Source: "fn: last", + Start: ast.Position{ + Column: 39, + Line: 55, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 41, + Line: 55, + }, + File: "join_two_same_sources_test.flux", + Source: "fn", + Start: ast.Position{ + Column: 39, + Line: 55, + }, + }, + }, + Name: "fn", + }, + Value: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 47, + Line: 55, + }, + File: "join_two_same_sources_test.flux", + Source: "last", + Start: ast.Position{ + Column: 43, + Line: 55, + }, + }, + }, + Name: "last", + }, + }}, + With: nil, + }}, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 48, + Line: 55, + }, + File: "join_two_same_sources_test.flux", + Source: "aggregateWindow(every: 1s, fn: last)", + Start: ast.Position{ + Column: 12, + Line: 55, + }, + }, + }, + Callee: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 27, + Line: 55, + }, + File: "join_two_same_sources_test.flux", + Source: "aggregateWindow", + Start: ast.Position{ + Column: 12, + Line: 55, + }, + }, + }, + Name: "aggregateWindow", + }, + }, + }, + }, &ast.VariableAssignment{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 48, + Line: 60, + }, + File: "join_two_same_sources_test.flux", + Source: "data_2 = table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"guild\")\n |> aggregateWindow(every: 1s, fn: last)", + Start: ast.Position{ + Column: 5, + Line: 57, + }, + }, + }, + ID: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 11, + Line: 57, + }, + File: "join_two_same_sources_test.flux", + Source: "data_2", + Start: ast.Position{ + Column: 5, + Line: 57, + }, + }, + }, + Name: "data_2", + }, + Init: &ast.PipeExpression{ + Argument: &ast.PipeExpression{ + Argument: &ast.PipeExpression{ + Argument: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 19, + Line: 57, + }, + File: "join_two_same_sources_test.flux", + Source: "table", + Start: ast.Position{ + Column: 14, + Line: 57, + }, + }, + }, + Name: "table", + }, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 74, + Line: 58, + }, + File: "join_two_same_sources_test.flux", + Source: "table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)", + Start: ast.Position{ + Column: 14, + Line: 57, + }, + }, + }, + Call: &ast.CallExpression{ + Arguments: []ast.Expression{&ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 73, + Line: 58, + }, + File: "join_two_same_sources_test.flux", + Source: "start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z", + Start: ast.Position{ + Column: 18, + Line: 58, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 45, + Line: 58, + }, + File: "join_two_same_sources_test.flux", + Source: "start: 2018-12-19T22:13:30Z", + Start: ast.Position{ + Column: 18, + Line: 58, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 23, + Line: 58, + }, + File: "join_two_same_sources_test.flux", + Source: "start", + Start: ast.Position{ + Column: 18, + Line: 58, + }, + }, + }, + Name: "start", + }, + Value: &ast.DateTimeLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 45, + Line: 58, + }, + File: "join_two_same_sources_test.flux", + Source: "2018-12-19T22:13:30Z", + Start: ast.Position{ + Column: 25, + Line: 58, + }, + }, + }, + Value: parser.MustParseTime("2018-12-19T22:13:30Z"), + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 73, + Line: 58, + }, + File: "join_two_same_sources_test.flux", + Source: "stop: 2018-12-19T22:13:50Z", + Start: ast.Position{ + Column: 47, + Line: 58, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 51, + Line: 58, + }, + File: "join_two_same_sources_test.flux", + Source: "stop", + Start: ast.Position{ + Column: 47, + Line: 58, + }, + }, + }, + Name: "stop", + }, + Value: &ast.DateTimeLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 73, + Line: 58, + }, + File: "join_two_same_sources_test.flux", + Source: "2018-12-19T22:13:50Z", + Start: ast.Position{ + Column: 53, + Line: 58, + }, + }, + }, + Value: parser.MustParseTime("2018-12-19T22:13:50Z"), + }, + }}, + With: nil, + }}, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 74, + Line: 58, + }, + File: "join_two_same_sources_test.flux", + Source: "range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)", + Start: ast.Position{ + Column: 12, + Line: 58, + }, + }, + }, + Callee: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 17, + Line: 58, + }, + File: "join_two_same_sources_test.flux", + Source: "range", + Start: ast.Position{ + Column: 12, + Line: 58, + }, + }, + }, + Name: "range", + }, + }, + }, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 82, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"guild\")", + Start: ast.Position{ + Column: 14, + Line: 57, + }, + }, + }, + Call: &ast.CallExpression{ + Arguments: []ast.Expression{&ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 81, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "fn: (r) => r._measurement == \"command\" and r._field == \"guild\"", + Start: ast.Position{ + Column: 19, + Line: 59, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 81, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "fn: (r) => r._measurement == \"command\" and r._field == \"guild\"", + Start: ast.Position{ + Column: 19, + Line: 59, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 21, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "fn", + Start: ast.Position{ + Column: 19, + Line: 59, + }, + }, + }, + Name: "fn", + }, + Value: &ast.FunctionExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 81, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "(r) => r._measurement == \"command\" and r._field == \"guild\"", + Start: ast.Position{ + Column: 23, + Line: 59, + }, + }, + }, + Body: &ast.LogicalExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 81, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "r._measurement == \"command\" and r._field == \"guild\"", + Start: ast.Position{ + Column: 30, + Line: 59, + }, + }, + }, + Left: &ast.BinaryExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 57, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "r._measurement == \"command\"", + Start: ast.Position{ + Column: 30, + Line: 59, + }, + }, + }, + Left: &ast.MemberExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 44, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "r._measurement", + Start: ast.Position{ + Column: 30, + Line: 59, + }, + }, + }, + Object: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 31, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "r", + Start: ast.Position{ + Column: 30, + Line: 59, + }, + }, + }, + Name: "r", + }, + Property: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 44, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "_measurement", + Start: ast.Position{ + Column: 32, + Line: 59, + }, + }, + }, + Name: "_measurement", + }, + }, + Operator: 17, + Right: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 57, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "\"command\"", + Start: ast.Position{ + Column: 48, + Line: 59, + }, + }, + }, + Value: "command", + }, + }, + Operator: 1, + Right: &ast.BinaryExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 81, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "r._field == \"guild\"", + Start: ast.Position{ + Column: 62, + Line: 59, + }, + }, + }, + Left: &ast.MemberExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 70, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "r._field", + Start: ast.Position{ + Column: 62, + Line: 59, + }, + }, + }, + Object: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 63, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "r", + Start: ast.Position{ + Column: 62, + Line: 59, + }, + }, + }, + Name: "r", + }, + Property: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 70, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "_field", + Start: ast.Position{ + Column: 64, + Line: 59, + }, + }, + }, + Name: "_field", + }, + }, + Operator: 17, + Right: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 81, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "\"guild\"", + Start: ast.Position{ + Column: 74, + Line: 59, + }, + }, + }, + Value: "guild", + }, + }, + }, + Params: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 25, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "r", + Start: ast.Position{ + Column: 24, + Line: 59, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 25, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "r", + Start: ast.Position{ + Column: 24, + Line: 59, + }, + }, + }, + Name: "r", + }, + Value: nil, + }}, + }, + }}, + With: nil, + }}, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 82, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "filter(fn: (r) => r._measurement == \"command\" and r._field == \"guild\")", + Start: ast.Position{ + Column: 12, + Line: 59, + }, + }, + }, + Callee: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 18, + Line: 59, + }, + File: "join_two_same_sources_test.flux", + Source: "filter", + Start: ast.Position{ + Column: 12, + Line: 59, + }, + }, + }, + Name: "filter", + }, + }, + }, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 48, + Line: 60, + }, + File: "join_two_same_sources_test.flux", + Source: "table\n |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z)\n |> filter(fn: (r) => r._measurement == \"command\" and r._field == \"guild\")\n |> aggregateWindow(every: 1s, fn: last)", + Start: ast.Position{ + Column: 14, + Line: 57, + }, + }, + }, + Call: &ast.CallExpression{ + Arguments: []ast.Expression{&ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 47, + Line: 60, + }, + File: "join_two_same_sources_test.flux", + Source: "every: 1s, fn: last", + Start: ast.Position{ + Column: 28, + Line: 60, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 37, + Line: 60, + }, + File: "join_two_same_sources_test.flux", + Source: "every: 1s", + Start: ast.Position{ + Column: 28, + Line: 60, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 33, + Line: 60, + }, + File: "join_two_same_sources_test.flux", + Source: "every", + Start: ast.Position{ + Column: 28, + Line: 60, + }, + }, + }, + Name: "every", + }, + Value: &ast.DurationLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 37, + Line: 60, + }, + File: "join_two_same_sources_test.flux", + Source: "1s", + Start: ast.Position{ + Column: 35, + Line: 60, + }, + }, + }, + Values: []ast.Duration{ast.Duration{ + Magnitude: int64(1), + Unit: "s", + }}, + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 47, + Line: 60, + }, + File: "join_two_same_sources_test.flux", + Source: "fn: last", + Start: ast.Position{ + Column: 39, + Line: 60, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 41, + Line: 60, + }, + File: "join_two_same_sources_test.flux", + Source: "fn", + Start: ast.Position{ + Column: 39, + Line: 60, + }, + }, + }, + Name: "fn", + }, + Value: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 47, + Line: 60, + }, + File: "join_two_same_sources_test.flux", + Source: "last", + Start: ast.Position{ + Column: 43, + Line: 60, + }, + }, + }, + Name: "last", + }, + }}, + With: nil, + }}, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 48, + Line: 60, + }, + File: "join_two_same_sources_test.flux", + Source: "aggregateWindow(every: 1s, fn: last)", + Start: ast.Position{ + Column: 12, + Line: 60, + }, + }, + }, + Callee: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 27, + Line: 60, + }, + File: "join_two_same_sources_test.flux", + Source: "aggregateWindow", + Start: ast.Position{ + Column: 12, + Line: 60, + }, + }, + }, + Name: "aggregateWindow", + }, + }, + }, + }, &ast.ReturnStatement{ + Argument: &ast.CallExpression{ + Arguments: []ast.Expression{&ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 64, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "tables: {d1: data_1, d2: data_2}, on: [\"_time\"]", + Start: ast.Position{ + Column: 17, + Line: 62, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 49, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "tables: {d1: data_1, d2: data_2}", + Start: ast.Position{ + Column: 17, + Line: 62, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 23, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "tables", + Start: ast.Position{ + Column: 17, + Line: 62, + }, + }, + }, + Name: "tables", + }, + Value: &ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 49, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "{d1: data_1, d2: data_2}", + Start: ast.Position{ + Column: 25, + Line: 62, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 36, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "d1: data_1", + Start: ast.Position{ + Column: 26, + Line: 62, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 28, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "d1", + Start: ast.Position{ + Column: 26, + Line: 62, + }, + }, + }, + Name: "d1", + }, + Value: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 36, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "data_1", + Start: ast.Position{ + Column: 30, + Line: 62, + }, + }, + }, + Name: "data_1", + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 48, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "d2: data_2", + Start: ast.Position{ + Column: 38, + Line: 62, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "d2", + Start: ast.Position{ + Column: 38, + Line: 62, + }, + }, + }, + Name: "d2", + }, + Value: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 48, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "data_2", + Start: ast.Position{ + Column: 42, + Line: 62, + }, + }, + }, + Name: "data_2", + }, + }}, + With: nil, + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 64, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "on: [\"_time\"]", + Start: ast.Position{ + Column: 51, + Line: 62, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 53, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "on", + Start: ast.Position{ + Column: 51, + Line: 62, + }, + }, + }, + Name: "on", + }, + Value: &ast.ArrayExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 64, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "[\"_time\"]", + Start: ast.Position{ + Column: 55, + Line: 62, + }, + }, + }, + Elements: []ast.Expression{&ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 63, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "\"_time\"", + Start: ast.Position{ + Column: 56, + Line: 62, + }, + }, + }, + Value: "_time", + }}, + }, + }}, + With: nil, + }}, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 65, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "join(tables: {d1: data_1, d2: data_2}, on: [\"_time\"])", + Start: ast.Position{ + Column: 12, + Line: 62, + }, + }, + }, + Callee: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 16, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "join", + Start: ast.Position{ + Column: 12, + Line: 62, + }, + }, + }, + Name: "join", + }, + }, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 65, + Line: 62, + }, + File: "join_two_same_sources_test.flux", + Source: "return join(tables: {d1: data_1, d2: data_2}, on: [\"_time\"])", + Start: ast.Position{ + Column: 5, + Line: 62, + }, + }, + }, + }}, + }, + Params: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 36, + Line: 51, + }, + File: "join_two_same_sources_test.flux", + Source: "table=<-", + Start: ast.Position{ + Column: 28, + Line: 51, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 33, + Line: 51, + }, + File: "join_two_same_sources_test.flux", + Source: "table", + Start: ast.Position{ + Column: 28, + Line: 51, + }, + }, + }, + Name: "table", + }, + Value: &ast.PipeLiteral{BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 36, + Line: 51, + }, + File: "join_two_same_sources_test.flux", + Source: "<-", + Start: ast.Position{ + Column: 34, + Line: 51, + }, + }, + }}, + }}, + }, + }, &ast.TestStatement{ + Assignment: &ast.VariableAssignment{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 93, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "_join_two_same_sources = () =>\n ({input: get_input(), want: testing.loadMem(csv: outData), fn: t_join_two_same_sources})", + Start: ast.Position{ + Column: 6, + Line: 65, + }, + }, + }, + ID: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 28, + Line: 65, + }, + File: "join_two_same_sources_test.flux", + Source: "_join_two_same_sources", + Start: ast.Position{ + Column: 6, + Line: 65, + }, + }, + }, + Name: "_join_two_same_sources", + }, + Init: &ast.FunctionExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 93, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "() =>\n ({input: get_input(), want: testing.loadMem(csv: outData), fn: t_join_two_same_sources})", + Start: ast.Position{ + Column: 31, + Line: 65, + }, + }, + }, + Body: &ast.ParenExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 93, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "({input: get_input(), want: testing.loadMem(csv: outData), fn: t_join_two_same_sources})", + Start: ast.Position{ + Column: 5, + Line: 66, + }, + }, + }, + Expression: &ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 92, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "{input: get_input(), want: testing.loadMem(csv: outData), fn: t_join_two_same_sources}", + Start: ast.Position{ + Column: 6, + Line: 66, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 25, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "input: get_input()", + Start: ast.Position{ + Column: 7, + Line: 66, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 12, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "input", + Start: ast.Position{ + Column: 7, + Line: 66, + }, + }, + }, + Name: "input", + }, + Value: &ast.CallExpression{ + Arguments: nil, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 25, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "get_input()", + Start: ast.Position{ + Column: 14, + Line: 66, + }, + }, + }, + Callee: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 23, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "get_input", + Start: ast.Position{ + Column: 14, + Line: 66, + }, + }, + }, + Name: "get_input", + }, + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 62, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "want: testing.loadMem(csv: outData)", + Start: ast.Position{ + Column: 27, + Line: 66, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 31, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "want", + Start: ast.Position{ + Column: 27, + Line: 66, + }, + }, + }, + Name: "want", + }, + Value: &ast.CallExpression{ + Arguments: []ast.Expression{&ast.ObjectExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 61, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "csv: outData", + Start: ast.Position{ + Column: 49, + Line: 66, + }, + }, + }, + Properties: []*ast.Property{&ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 61, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "csv: outData", + Start: ast.Position{ + Column: 49, + Line: 66, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 52, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "csv", + Start: ast.Position{ + Column: 49, + Line: 66, + }, + }, + }, + Name: "csv", + }, + Value: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 61, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "outData", + Start: ast.Position{ + Column: 54, + Line: 66, + }, + }, + }, + Name: "outData", + }, + }}, + With: nil, + }}, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 62, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "testing.loadMem(csv: outData)", + Start: ast.Position{ + Column: 33, + Line: 66, + }, + }, + }, + Callee: &ast.MemberExpression{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 48, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "testing.loadMem", + Start: ast.Position{ + Column: 33, + Line: 66, + }, + }, + }, + Object: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 40, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "testing", + Start: ast.Position{ + Column: 33, + Line: 66, + }, + }, + }, + Name: "testing", + }, + Property: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 48, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "loadMem", + Start: ast.Position{ + Column: 41, + Line: 66, + }, + }, + }, + Name: "loadMem", + }, + }, + }, + }, &ast.Property{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 91, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "fn: t_join_two_same_sources", + Start: ast.Position{ + Column: 64, + Line: 66, + }, + }, + }, + Key: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 66, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "fn", + Start: ast.Position{ + Column: 64, + Line: 66, + }, + }, + }, + Name: "fn", + }, + Value: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 91, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "t_join_two_same_sources", + Start: ast.Position{ + Column: 68, + Line: 66, + }, + }, + }, + Name: "t_join_two_same_sources", + }, + }}, + With: nil, + }, + }, + Params: []*ast.Property{}, + }, + }, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 93, + Line: 66, + }, + File: "join_two_same_sources_test.flux", + Source: "test _join_two_same_sources = () =>\n ({input: get_input(), want: testing.loadMem(csv: outData), fn: t_join_two_same_sources})", + Start: ast.Position{ + Column: 1, + Line: 65, + }, + }, + }, + }}, + Imports: []*ast.ImportDeclaration{&ast.ImportDeclaration{ + As: nil, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 17, + Line: 3, + }, + File: "join_two_same_sources_test.flux", + Source: "import \"testing\"", + Start: ast.Position{ + Column: 1, + Line: 3, + }, + }, + }, + Path: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 17, + Line: 3, + }, + File: "join_two_same_sources_test.flux", + Source: "\"testing\"", + Start: ast.Position{ + Column: 8, + Line: 3, + }, + }, + }, + Value: "testing", + }, + }, &ast.ImportDeclaration{ + As: nil, + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 28, + Line: 4, + }, + File: "join_two_same_sources_test.flux", + Source: "import \"experimental/array\"", + Start: ast.Position{ + Column: 1, + Line: 4, + }, + }, + }, + Path: &ast.StringLiteral{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 28, + Line: 4, + }, + File: "join_two_same_sources_test.flux", + Source: "\"experimental/array\"", + Start: ast.Position{ + Column: 8, + Line: 4, + }, + }, + }, + Value: "experimental/array", + }, + }}, + Metadata: "parser-type=rust", + Name: "join_two_same_sources_test.flux", + Package: &ast.PackageClause{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 22, + Line: 1, + }, + File: "join_two_same_sources_test.flux", + Source: "package universe_test", + Start: ast.Position{ + Column: 1, + Line: 1, + }, + }, + }, + Name: &ast.Identifier{ + BaseNode: ast.BaseNode{ + Errors: nil, + Loc: &ast.SourceLocation{ + End: ast.Position{ + Column: 22, + Line: 1, + }, + File: "join_two_same_sources_test.flux", + Source: "universe_test", + Start: ast.Position{ + Column: 9, + Line: 1, + }, + }, + }, + Name: "universe_test", + }, + }, }, &ast.File{ BaseNode: ast.BaseNode{ Errors: nil, diff --git a/stdlib/universe/join_two_same_sources_test.flux b/stdlib/universe/join_two_same_sources_test.flux new file mode 100644 index 0000000000..3c2bd6c14e --- /dev/null +++ b/stdlib/universe/join_two_same_sources_test.flux @@ -0,0 +1,66 @@ +package universe_test + +import "testing" +import "experimental/array" + +inData = array.from(rows: [ + { + _measurement: "command", + _field: "id", + _time: 2018-12-19T22:13:30.005Z, + _value: 12, + }, { + _measurement: "command", + _field: "id", + _time: 2018-12-19T22:13:40.005Z, + _value: 23, + }, { + _measurement: "command", + _field: "id", + _time: 2018-12-19T22:13:50.005Z, + _value: 34, + }, { + _measurement: "command", + _field: "guild", + _time: 2018-12-19T22:13:30.005Z, + _value: 12, + }, { + _measurement: "command", + _field: "guild", + _time: 2018-12-19T22:13:40.005Z, + _value: 23, + }, { + _measurement: "command", + _field: "guild", + _time: 2018-12-19T22:13:50.005Z, + _value: 34, + } +]) + +get_input = () => (inData) + +outData = " +#group,false,false,false,false,false,false,true,true,true,true,false,false,false +#datatype,string,long,string,string,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,long,long +#default,_result,,,,,,,,,,,, +,result,table,_field_d1,_field_d2,_measurement_d1,_measurement_d2,_start_d1,_start_d2,_stop_d1,_stop_d2,_time,_value_d1,_value_d2 +,,0,id,guild,command,command,2018-12-19T22:13:30Z,2018-12-19T22:13:30Z,2018-12-19T22:13:50Z,2018-12-19T22:13:50Z,2018-12-19T22:13:31Z,12,12 +,,0,id,guild,command,command,2018-12-19T22:13:30Z,2018-12-19T22:13:30Z,2018-12-19T22:13:50Z,2018-12-19T22:13:50Z,2018-12-19T22:13:41Z,23,23 +" + +t_join_two_same_sources = (table=<-) => { + data_1 = table + |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z) + |> filter(fn: (r) => r._measurement == "command" and r._field == "id") + |> aggregateWindow(every: 1s, fn: last) + + data_2 = table + |> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:13:50Z) + |> filter(fn: (r) => r._measurement == "command" and r._field == "guild") + |> aggregateWindow(every: 1s, fn: last) + + return join(tables: {d1: data_1, d2: data_2}, on: ["_time"]) +} + +test _join_two_same_sources = () => + ({input: get_input(), want: testing.loadMem(csv: outData), fn: t_join_two_same_sources}) From ac33aca9acc62114f54d3bcd61357545e8b9e842 Mon Sep 17 00:00:00 2001 From: Yiqun Zhang Date: Mon, 2 Nov 2020 01:26:19 -0600 Subject: [PATCH 4/5] chore: add TestPlanNodeUniqueness --- lang/query_test.go | 142 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/lang/query_test.go b/lang/query_test.go index 304e8e482d..56c0cf54be 100644 --- a/lang/query_test.go +++ b/lang/query_test.go @@ -2,9 +2,11 @@ package lang_test import ( "context" + "fmt" "testing" "time" + "github.com/google/go-cmp/cmp" "github.com/influxdata/flux" _ "github.com/influxdata/flux/builtin" "github.com/influxdata/flux/execute/executetest" @@ -167,3 +169,143 @@ csv.from(csv: data) |> map(fn: (r) => r.nonexistent)` t.Fatalf("unexpected error from query execution: %s", q.Err()) } } + +// This test verifies that when a query involves table functions or chain(), the plan nodes +// the main query generates does not reuse the node IDs that are already used by the table +// functions or chain() +func TestPlanNodeUniqueness(t *testing.T) { + prelude := ` +import "experimental/array" +import "experimental" + +data = array.from(rows: [{ +_measurement: "command", +_field: "id", +_time: 2018-12-19T22:13:30Z, +_value: 12, +}, { +_measurement: "command", +_field: "id", +_time: 2018-12-19T22:13:40Z, +_value: 23, +}, { +_measurement: "command", +_field: "id", +_time: 2018-12-19T22:13:50Z, +_value: 34, +}, { +_measurement: "command", +_field: "guild", +_time: 2018-12-19T22:13:30Z, +_value: 12, +}, { +_measurement: "command", +_field: "guild", +_time: 2018-12-19T22:13:40Z, +_value: 23, +}, { +_measurement: "command", +_field: "guild", +_time: 2018-12-19T22:13:50Z, +_value: 34, +}]) +` + tcs := []struct{ + name string + script string + want string + }{ + { + name: "chain", + script: ` +id = data +|> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:14:21Z) +|> filter(fn: (r) => r["_field"] == "id") + +guild = data +|> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:14:21Z) +|> filter(fn: (r) => r["_field"] == "guild") + +experimental.chain(first: id, second: guild) +`, + want: `[digraph { + experimental/array.from0 + range1 + filter2 + // r._field == "id" + generated_yield + + experimental/array.from0 -> range1 + range1 -> filter2 + filter2 -> generated_yield +} + digraph { + experimental/array.from3 + range4 + filter5 + // r._field == "guild" + generated_yield + + experimental/array.from3 -> range4 + range4 -> filter5 + filter5 -> generated_yield +} +]`, + }, + { + name: "tableFns", + script: ` +ids = data +|> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:14:21Z) +|> filter(fn: (r) => r["_field"] == "id") +|> sort() +|> tableFind(fn: (key) => true) +|> getColumn(column: "_field") + +id = ids[0] + +data +|> range(start: 2018-12-19T22:13:30Z, stop: 2018-12-19T22:14:21Z) +|> filter(fn: (r) => r["_field"] == id) +`, + want: `[digraph { + experimental/array.from0 + range1 + filter2 + // r._field == "id" + sort3 + generated_yield + + experimental/array.from0 -> range1 + range1 -> filter2 + filter2 -> sort3 + sort3 -> generated_yield +} + digraph { + experimental/array.from4 + range5 + filter6 + // r._field == "id" + generated_yield + + experimental/array.from4 -> range5 + range5 -> filter6 + filter6 -> generated_yield +} +]`, + }, + } + + for _, tc := range tcs { + t.Run(tc.name, func(t *testing.T) { + if q, err := runQuery(prelude + tc.script); err != nil { + t.Error(err) + } else { + got := fmt.Sprintf("%v", q.Statistics().Metadata["flux/query-plan"]) + if !cmp.Equal(tc.want, got) { + t.Errorf("unexpected value -want/+got\n%s", cmp.Diff(tc.want, got)) + } + } + }) + } +} From 3f1cd77e20aedfa9d92383a0f49398761e809d93 Mon Sep 17 00:00:00 2001 From: Yiqun Zhang Date: Mon, 2 Nov 2020 01:26:33 -0600 Subject: [PATCH 5/5] chore: fmt --- lang/query_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lang/query_test.go b/lang/query_test.go index 56c0cf54be..a52d7c4838 100644 --- a/lang/query_test.go +++ b/lang/query_test.go @@ -210,10 +210,10 @@ _time: 2018-12-19T22:13:50Z, _value: 34, }]) ` - tcs := []struct{ - name string + tcs := []struct { + name string script string - want string + want string }{ { name: "chain",