Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plan): fix logic bug in planner helper method #5115

Merged
merged 2 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libflux/go/libflux/buildinfo.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions plan/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Comment on lines +268 to +269
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the bug was caused by this code block using the wrong index? Do I have that right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right. We are looking at the predecessors of the node being replaced, and updating them to point at the new node. But we were using the index from the list of predecessors (which we are not changing) instead of the index from the predecessors' successors.

if succ == bottom {
pred.Successors()[i] = merged
}
Expand Down
34 changes: 34 additions & 0 deletions stdlib/universe/sort_limit_test.flux
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}