Skip to content

Commit

Permalink
[coordinator] Include Type in RollupOp.Equal (#3322)
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyk authored Mar 4, 2021
1 parent 100b867 commit 1699ee2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/metrics/pipeline/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ func (op RollupOp) Equal(other RollupOp) bool {
if !op.AggregationID.Equal(other.AggregationID) {
return false
}
if op.Type != other.Type {
return false
}
return op.SameTransform(other)
}

Expand Down
29 changes: 29 additions & 0 deletions src/metrics/pipeline/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,35 @@ func TestTransformationOpRoundTrip(t *testing.T) {
require.Equal(t, testTransformationOp, res)
}

func TestRollupOpEqual(t *testing.T) {
inputs := []struct {
a1 RollupOp
a2 RollupOp
expected bool
}{
{
a1: RollupOp{Type: GroupByRollupType},
a2: RollupOp{Type: GroupByRollupType},
expected: true,
},
{
a1: RollupOp{Type: ExcludeByRollupType},
a2: RollupOp{Type: ExcludeByRollupType},
expected: true,
},
{
a1: RollupOp{Type: GroupByRollupType},
a2: RollupOp{Type: ExcludeByRollupType},
expected: false,
},
}

for _, input := range inputs {
require.Equal(t, input.expected, input.a1.Equal(input.a2))
require.Equal(t, input.expected, input.a2.Equal(input.a1))
}
}

func TestRollupOpSameTransform(t *testing.T) {
rollupOp := RollupOp{
newName: b("foo"),
Expand Down

0 comments on commit 1699ee2

Please sign in to comment.