diff --git a/pkg/logql/syntax/serialize.go b/pkg/logql/syntax/serialize.go index b82f19001e76e..f5c5246ce85c5 100644 --- a/pkg/logql/syntax/serialize.go +++ b/pkg/logql/syntax/serialize.go @@ -257,7 +257,6 @@ func (v *JSONSerializer) VisitVector(e *VectorExpr) { v.WriteObjectField("vector") v.WriteObjectStart() - v.WriteMore() v.WriteObjectField("val") v.WriteFloat64(e.Val) diff --git a/pkg/logql/syntax/serialize_test.go b/pkg/logql/syntax/serialize_test.go index 302b66f22af35..80681d7f23103 100644 --- a/pkg/logql/syntax/serialize_test.go +++ b/pkg/logql/syntax/serialize_test.go @@ -32,6 +32,12 @@ func TestJSONSerializationRoundTrip(t *testing.T) { "vector matching": { query: `(sum by (cluster)(rate({foo="bar"}[5m])) / ignoring (cluster) count(rate({foo="bar"}[5m])))`, }, + "sum over or vector": { + query: `(sum(count_over_time({foo="bar"}[5m])) or vector(1.000000))`, + }, + "label replace": { + query: `label_replace(vector(0), "foo", "bar", "", "")`, + }, } for name, test := range tests { @@ -55,7 +61,7 @@ func TestJSONSerializationRoundTrip(t *testing.T) { } func TestJSONSerializationParseTestCases(t *testing.T) { for _, tc := range ParseTestCases { - if tc.err != nil { + if tc.err == nil { t.Run(tc.in, func(t *testing.T) { ast, err := ParseExpr(tc.in) require.NoError(t, err)