Skip to content

Commit

Permalink
MQE: fix incorrect query results or "found duplicate series for the m…
Browse files Browse the repository at this point in the history
…atch group" errors when binary operation has unsorted labels in `on`
  • Loading branch information
charleskorn committed Oct 1, 2024
1 parent 97f0319 commit a24775e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ func (b *VectorVectorBinaryOperation) groupKeyFunc() func(labels.Labels) []byte
buf := make([]byte, 0, 1024)

if b.VectorMatching.On {
slices.Sort(b.VectorMatching.MatchingLabels)

return func(l labels.Labels) []byte {
return l.BytesWithLabels(buf, b.VectorMatching.MatchingLabels...)
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/streamingpromql/testdata/ours/binary_operators.test
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,21 @@ eval range from 0 to 24m step 6m left_side - on(env, pod) right_side
{env="test", pod="a"} -9 -18 -27
{env="test", pod="b"} -36 -45 -54

eval range from 0 to 24m step 6m left_side - on(pod, env) right_side
{env="prod", pod="a"} -63 -72 -81
{env="test", pod="a"} -9 -18 -27
{env="test", pod="b"} -36 -45 -54

eval range from 0 to 24m step 6m left_side - ignoring(env, pod) right_side
{group="baz"} -33 -42 -51
{group="bar"} -6 -15 -24
{group="foo"} -69 -78 -87

eval range from 0 to 24m step 6m left_side - ignoring(pod, env) right_side
{group="baz"} -33 -42 -51
{group="bar"} -6 -15 -24
{group="foo"} -69 -78 -87

clear

# One-to-one matching, but different series match at different time steps, or not at all
Expand Down

0 comments on commit a24775e

Please sign in to comment.