From ac9b8275bf20a63b84ea7b36fc43ab9d8027946f Mon Sep 17 00:00:00 2001 From: "Christopher M. Wolff" Date: Fri, 19 Aug 2022 12:06:19 -0700 Subject: [PATCH] fix(plan): fix logic bug in planner helper method (#5115) Fixes #5114. --- libflux/go/libflux/buildinfo.gen.go | 2 +- plan/types.go | 4 ++-- stdlib/universe/sort_limit_test.flux | 34 ++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/libflux/go/libflux/buildinfo.gen.go b/libflux/go/libflux/buildinfo.gen.go index 0ae3a31018..29b3e61244 100644 --- a/libflux/go/libflux/buildinfo.gen.go +++ b/libflux/go/libflux/buildinfo.gen.go @@ -581,7 +581,7 @@ var sourceHashes = map[string]string{ "stdlib/universe/simple_max_test.flux": "a63b3f530e4d81451e3c71a1abeea50cff02e743c9313ab3ffd5bc3b3ce9ad2e", "stdlib/universe/skew_test.flux": "7782d41c563c77ba9f4176fa1b5f4f6107e418b7ea301e4896398dbcb514315a", "stdlib/universe/sort2_test.flux": "1d2043c0d0b38abb8dc61fc1baa6d6052fae63fea55cc6e67fd1600911513bdb", - "stdlib/universe/sort_limit_test.flux": "c595da9613faf8734932d8c2e63291517b7842b5656f795b32d50e987493ec2a", + "stdlib/universe/sort_limit_test.flux": "32825b6b789c5b3287ae72967687a63fa3fee783e6626426c9b1cc7f39306dc8", "stdlib/universe/sort_rules_test.flux": "0770ae42e99b04167ca5bef8340a310b224baf1ba1928997273de9663b64684a", "stdlib/universe/sort_test.flux": "f69ebb5972762078e759af3c1cd3d852431a569dce74f3c379709c9e174bfa31", "stdlib/universe/spread_test.flux": "1ddf25e4d86b6365da254229fc8f77bd838c24a79e6a08c9c4c50330ace0a6a3", diff --git a/plan/types.go b/plan/types.go index d4e6b865ab..d1e5625cb8 100644 --- a/plan/types.go +++ b/plan/types.go @@ -265,8 +265,8 @@ func mergePlanNodes(top, bottom, merged Node) (Node, error) { } merged.AddPredecessors(bottom.Predecessors()...) - for i, pred := range merged.Predecessors() { - for _, succ := range pred.Successors() { + for _, pred := range merged.Predecessors() { + for i, succ := range pred.Successors() { if succ == bottom { pred.Successors()[i] = merged } diff --git a/stdlib/universe/sort_limit_test.flux b/stdlib/universe/sort_limit_test.flux index ac9e533aa5..6fc7be937c 100644 --- a/stdlib/universe/sort_limit_test.flux +++ b/stdlib/universe/sort_limit_test.flux @@ -138,3 +138,37 @@ testcase sort_limit_zero_row_table { testing.diff(got, want) } + +testcase sort_limit_multi_successor { + input = + array.from( + rows: [ + {_time: 2022-01-11T00:00:00Z, _value: 10.0}, + {_time: 2022-01-11T01:00:00Z, _value: 12.0}, + {_time: 2022-01-11T02:00:00Z, _value: 18.0}, + {_time: 2022-01-11T03:00:00Z, _value: 4.0}, + {_time: 2022-01-11T04:00:00Z, _value: 8.0}, + ], + ) + in0 = + input + |> bottom(n: 2) + in1 = + input + |> top(n: 2) + got = + union(tables: [in0, in1]) + |> sort(columns: ["_time"]) + + want = + array.from( + rows: [ + {_time: 2022-01-11T01:00:00Z, _value: 12.0}, + {_time: 2022-01-11T02:00:00Z, _value: 18.0}, + {_time: 2022-01-11T03:00:00Z, _value: 4.0}, + {_time: 2022-01-11T04:00:00Z, _value: 8.0}, + ], + ) + + testing.diff(got: got, want: want) +}