MCPcopy
hub / github.com/grafana/tempo / TestScalarExpressionOperators

Function TestScalarExpressionOperators

pkg/traceql/parse_test.go:744–766  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

742}
743
744func TestScalarExpressionOperators(t *testing.T) {
745 tests := []struct {
746 in string
747 expected ScalarFilter
748 expectedStr string
749 }{
750 {in: "count() > 1", expected: newScalarFilter(OpGreater, newAggregate(aggregateCount, nil), NewStaticInt(1)), expectedStr: "(count()) > 1"},
751 {in: "max(.a) > 1", expected: newScalarFilter(OpGreater, newAggregate(aggregateMax, NewAttribute("a")), NewStaticInt(1)), expectedStr: "(max(.a)) > 1"},
752 {in: "min(1) > 1", expected: newScalarFilter(OpGreater, newAggregate(aggregateMin, NewStaticInt(1)), NewStaticInt(1)), expectedStr: "(min(1)) > 1"},
753 {in: "sum(true) > 1", expected: newScalarFilter(OpGreater, newAggregate(aggregateSum, NewStaticBool(true)), NewStaticInt(1)), expectedStr: "(sum(true)) > 1"},
754 {in: "avg(`c`) > 1", expected: newScalarFilter(OpGreater, newAggregate(aggregateAvg, NewStaticString("c")), NewStaticInt(1)), expectedStr: "(avg(`c`)) > 1"},
755 }
756
757 for _, tc := range tests {
758 t.Run(tc.in, func(t *testing.T) {
759 actual, err := Parse(tc.in)
760
761 require.NoError(t, err)
762 require.Equal(t, newRootExpr(newPipeline(tc.expected)), actual)
763 require.Equal(t, tc.expectedStr, actual.String())
764 })
765 }
766}
767
768func TestSpansetFilterErrors(t *testing.T) {
769 tests := []struct {

Callers

nothing calls this directly

Calls 12

newScalarFilterFunction · 0.85
newAggregateFunction · 0.85
NewStaticIntFunction · 0.85
NewAttributeFunction · 0.85
NewStaticBoolFunction · 0.85
NewStaticStringFunction · 0.85
ParseFunction · 0.85
newRootExprFunction · 0.85
newPipelineFunction · 0.85
RunMethod · 0.45
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected