This is an automated email from the ASF dual-hosted git repository. hanahmily pushed a commit to branch vectorized-query in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit 08762454659162fe76bf6d278e756c15b0b9e5ce Author: Hongtao Gao <[email protected]> AuthorDate: Fri May 15 10:25:43 2026 +0000 chore(query/vectorized/measure/plan): fix goconst/dogsled lint in G9 test files --- pkg/query/vectorized/measure/plan/analyzer_test.go | 67 ++++++++++++---------- pkg/query/vectorized/measure/plan/build_test.go | 16 +++--- pkg/query/vectorized/measure/plan/dispatch_test.go | 39 +++++++------ pkg/query/vectorized/measure/plan/executor_test.go | 16 +++--- 4 files changed, 73 insertions(+), 65 deletions(-) diff --git a/pkg/query/vectorized/measure/plan/analyzer_test.go b/pkg/query/vectorized/measure/plan/analyzer_test.go index 544b6fc5b..94197fc54 100644 --- a/pkg/query/vectorized/measure/plan/analyzer_test.go +++ b/pkg/query/vectorized/measure/plan/analyzer_test.go @@ -27,8 +27,13 @@ import ( modelv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v1" ) -// testMeasureSchema builds a minimal Measure schema with one "default" tag -// family containing "svc" + "region" tag specs and one "value" field. +const ( + tagSvc = "svc" + fieldValue = "value" +) + +// testMeasureSchema builds a minimal Measure schema with one default tag +// family containing the svc + region tag specs and one value field. func testMeasureSchema() *databasev1.Measure { return &databasev1.Measure{ Metadata: &commonv1.Metadata{Name: "demo", Group: "default"}, @@ -36,20 +41,20 @@ func testMeasureSchema() *databasev1.Measure { { Name: "default", Tags: []*databasev1.TagSpec{ - {Name: "svc", Type: databasev1.TagType_TAG_TYPE_STRING}, + {Name: tagSvc, Type: databasev1.TagType_TAG_TYPE_STRING}, {Name: "region", Type: databasev1.TagType_TAG_TYPE_STRING}, }, }, }, Fields: []*databasev1.FieldSpec{ - {Name: "value", FieldType: databasev1.FieldType_FIELD_TYPE_INT}, + {Name: fieldValue, FieldType: databasev1.FieldType_FIELD_TYPE_INT}, }, } } func projTagProj() *modelv1.TagProjection { return &modelv1.TagProjection{TagFamilies: []*modelv1.TagProjection_TagFamily{ - {Name: "default", Tags: []string{"svc"}}, + {Name: "default", Tags: []string{tagSvc}}, }} } @@ -57,7 +62,7 @@ func TestAnalyze_BareRequest_BuildsScanWrappedInLimit(t *testing.T) { req := &measurev1.QueryRequest{ Name: "demo", TagProjection: projTagProj(), - FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{"value"}}, + FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{fieldValue}}, } p, err := Analyze(req, testMeasureSchema()) if err != nil { @@ -75,14 +80,14 @@ func TestAnalyze_GroupByAgg_BuildsGroupByAggBelowLimit(t *testing.T) { req := &measurev1.QueryRequest{ Name: "demo", TagProjection: projTagProj(), - FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{"value"}}, + FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{fieldValue}}, GroupBy: &measurev1.QueryRequest_GroupBy{ TagProjection: projTagProj(), - FieldName: "value", + FieldName: fieldValue, }, Agg: &measurev1.QueryRequest_Aggregation{ Function: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM, - FieldName: "value", + FieldName: fieldValue, }, } p, err := Analyze(req, testMeasureSchema()) @@ -100,10 +105,10 @@ func TestAnalyze_GroupByAgg_BuildsGroupByAggBelowLimit(t *testing.T) { if _, ok := gba.Children()[0].(*Scan); !ok { t.Fatalf("GroupByAgg child should be *Scan, got %T", gba.Children()[0]) } - if gba.GroupBy.TagNames[0] != "svc" { + if gba.GroupBy.TagNames[0] != tagSvc { t.Fatalf("GroupBy.TagNames: want [svc], got %v", gba.GroupBy.TagNames) } - if gba.Agg.FieldName != "value" { + if gba.Agg.FieldName != fieldValue { t.Fatalf("Agg.FieldName: want value, got %s", gba.Agg.FieldName) } } @@ -112,14 +117,14 @@ func TestAnalyze_TopBetweenGroupByAggAndLimit(t *testing.T) { req := &measurev1.QueryRequest{ Name: "demo", TagProjection: projTagProj(), - FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{"value"}}, + FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{fieldValue}}, GroupBy: &measurev1.QueryRequest_GroupBy{ TagProjection: projTagProj(), - FieldName: "value", + FieldName: fieldValue, }, Agg: &measurev1.QueryRequest_Aggregation{ Function: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM, - FieldName: "value", + FieldName: fieldValue, }, Top: &measurev1.QueryRequest_Top{ Number: 5, @@ -155,10 +160,10 @@ func TestAnalyze_TopSortAsc_MapsToAscending(t *testing.T) { req := &measurev1.QueryRequest{ Name: "demo", TagProjection: projTagProj(), - FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{"value"}}, + FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{fieldValue}}, Top: &measurev1.QueryRequest_Top{ Number: 3, - FieldName: "value", + FieldName: fieldValue, FieldValueSort: modelv1.Sort_SORT_ASC, }, } @@ -185,10 +190,10 @@ func TestAnalyze_GroupByWithoutAgg_BuildsRawGroupBy(t *testing.T) { req := &measurev1.QueryRequest{ Name: "demo", TagProjection: projTagProj(), - FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{"value"}}, + FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{fieldValue}}, GroupBy: &measurev1.QueryRequest_GroupBy{ TagProjection: projTagProj(), - FieldName: "value", + FieldName: fieldValue, }, } p, err := Analyze(req, testMeasureSchema()) @@ -206,7 +211,7 @@ func TestAnalyze_GroupByWithoutAgg_BuildsRawGroupBy(t *testing.T) { if gba.Agg != nil { t.Fatalf("raw GroupBy must have nil Agg, got %+v", gba.Agg) } - if gba.GroupBy == nil || gba.GroupBy.TagNames[0] != "svc" { + if gba.GroupBy == nil || gba.GroupBy.TagNames[0] != tagSvc { t.Fatalf("GroupBy.TagNames: want [svc], got %+v", gba.GroupBy) } } @@ -217,10 +222,10 @@ func TestAnalyze_AggWithoutGroupBy_BuildsScalarReduce(t *testing.T) { req := &measurev1.QueryRequest{ Name: "demo", TagProjection: projTagProj(), - FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{"value"}}, + FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{fieldValue}}, Agg: &measurev1.QueryRequest_Aggregation{ Function: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM, - FieldName: "value", + FieldName: fieldValue, }, } p, err := Analyze(req, testMeasureSchema()) @@ -238,7 +243,7 @@ func TestAnalyze_AggWithoutGroupBy_BuildsScalarReduce(t *testing.T) { if gba.GroupBy != nil { t.Fatalf("scalar reduce must have nil GroupBy, got %+v", gba.GroupBy) } - if gba.Agg == nil || gba.Agg.FieldName != "value" { + if gba.Agg == nil || gba.Agg.FieldName != fieldValue { t.Fatalf("Agg.FieldName: want value, got %+v", gba.Agg) } } @@ -247,16 +252,16 @@ func TestAnalyze_UnknownGroupByTag_Errors(t *testing.T) { req := &measurev1.QueryRequest{ Name: "demo", TagProjection: projTagProj(), - FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{"value"}}, + FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{fieldValue}}, GroupBy: &measurev1.QueryRequest_GroupBy{ TagProjection: &modelv1.TagProjection{TagFamilies: []*modelv1.TagProjection_TagFamily{ {Name: "default", Tags: []string{"missing"}}, }}, - FieldName: "value", + FieldName: fieldValue, }, Agg: &measurev1.QueryRequest_Aggregation{ Function: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM, - FieldName: "value", + FieldName: fieldValue, }, } _, err := Analyze(req, testMeasureSchema()) @@ -272,10 +277,10 @@ func TestAnalyze_UnknownAggField_Errors(t *testing.T) { req := &measurev1.QueryRequest{ Name: "demo", TagProjection: projTagProj(), - FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{"value"}}, + FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{fieldValue}}, GroupBy: &measurev1.QueryRequest_GroupBy{ TagProjection: projTagProj(), - FieldName: "value", + FieldName: fieldValue, }, Agg: &measurev1.QueryRequest_Aggregation{ Function: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM, @@ -310,7 +315,7 @@ func TestAnalyze_DefaultLimit_AppliedWhenZero(t *testing.T) { req := &measurev1.QueryRequest{ Name: "demo", TagProjection: projTagProj(), - FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{"value"}}, + FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{fieldValue}}, // Limit unset (0) → default 100 per defaultLimit constant } p, err := Analyze(req, testMeasureSchema()) @@ -327,14 +332,14 @@ func TestPrintTree_RendersHierarchy(t *testing.T) { req := &measurev1.QueryRequest{ Name: "demo", TagProjection: projTagProj(), - FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{"value"}}, + FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{fieldValue}}, GroupBy: &measurev1.QueryRequest_GroupBy{ TagProjection: projTagProj(), - FieldName: "value", + FieldName: fieldValue, }, Agg: &measurev1.QueryRequest_Aggregation{ Function: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM, - FieldName: "value", + FieldName: fieldValue, }, } p, err := Analyze(req, testMeasureSchema()) diff --git a/pkg/query/vectorized/measure/plan/build_test.go b/pkg/query/vectorized/measure/plan/build_test.go index 88fc05a11..644873046 100644 --- a/pkg/query/vectorized/measure/plan/build_test.go +++ b/pkg/query/vectorized/measure/plan/build_test.go @@ -56,8 +56,8 @@ func buildScanInput(t *testing.T) (*vectorized.BatchSchema, *vectorized.RecordBa {Role: vectorized.RoleVersion, Type: vectorized.ColumnTypeInt64}, {Role: vectorized.RoleSeriesID, Type: vectorized.ColumnTypeInt64}, {Role: vectorized.RoleShardID, Type: vectorized.ColumnTypeInt64}, - {Role: vectorized.RoleTag, TagFamily: "default", Name: "svc", Type: vectorized.ColumnTypeString}, - {Role: vectorized.RoleField, Name: "value", Type: vectorized.ColumnTypeInt64}, + {Role: vectorized.RoleTag, TagFamily: "default", Name: tagSvc, Type: vectorized.ColumnTypeString}, + {Role: vectorized.RoleField, Name: fieldValue, Type: vectorized.ColumnTypeInt64}, }) b := vectorized.NewRecordBatch(schema, 5) pushRow := func(ts int64, svc string, v int64) { @@ -135,8 +135,8 @@ func TestScanGroupByAggLimit_Build_AggregatesByKey(t *testing.T) { scan := NewScan(schema, ScanParams{}) scan.Source = src gba, err := NewGroupByAgg(scan, - &model.MeasureGroupBy{TagFamily: "default", TagNames: []string{"svc"}}, - &model.MeasureAgg{FieldName: "value", Func: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM}, + &model.MeasureGroupBy{TagFamily: "default", TagNames: []string{tagSvc}}, + &model.MeasureAgg{FieldName: fieldValue, Func: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM}, ) if err != nil { t.Fatalf("NewGroupByAgg: %v", err) @@ -205,8 +205,8 @@ func TestGroupByAgg_Schema_DropsTimestampAddsAggField(t *testing.T) { scan := NewScan(schema, ScanParams{}) scan.Source = src gba, err := NewGroupByAgg(scan, - &model.MeasureGroupBy{TagFamily: "default", TagNames: []string{"svc"}}, - &model.MeasureAgg{FieldName: "value", Func: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM}, + &model.MeasureGroupBy{TagFamily: "default", TagNames: []string{tagSvc}}, + &model.MeasureAgg{FieldName: fieldValue, Func: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM}, ) if err != nil { t.Fatalf("NewGroupByAgg: %v", err) @@ -222,10 +222,10 @@ func TestGroupByAgg_Schema_DropsTimestampAddsAggField(t *testing.T) { if len(out.Columns) != 2 { t.Fatalf("want 2 output columns (key + agg result), got %d", len(out.Columns)) } - if out.Columns[0].Name != "svc" { + if out.Columns[0].Name != tagSvc { t.Fatalf("col 0 should be the svc key, got %s", out.Columns[0].Name) } - if out.Columns[1].Name != "value" { + if out.Columns[1].Name != fieldValue { t.Fatalf("col 1 should be 'value' (row-path parity), got %s", out.Columns[1].Name) } } diff --git a/pkg/query/vectorized/measure/plan/dispatch_test.go b/pkg/query/vectorized/measure/plan/dispatch_test.go index 2e2a979a8..3b9fcf0ec 100644 --- a/pkg/query/vectorized/measure/plan/dispatch_test.go +++ b/pkg/query/vectorized/measure/plan/dispatch_test.go @@ -42,7 +42,7 @@ func bareReq() *measurev1.QueryRequest { Name: "demo", Groups: []string{"default"}, TagProjection: projTagProj(), - FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{"value"}}, + FieldProjection: &measurev1.QueryRequest_FieldProjection{Names: []string{fieldValue}}, TimeRange: &modelv1.TimeRange{ Begin: timestamppb.New(time.Unix(0, 0)), End: timestamppb.New(time.Unix(0, 1_000_000)), @@ -72,7 +72,7 @@ func TestDispatch_GroupByWithoutAgg_FallsThrough(t *testing.T) { req := bareReq() req.GroupBy = &measurev1.QueryRequest_GroupBy{ TagProjection: projTagProj(), - FieldName: "value", + FieldName: fieldValue, } _, _, handled, err := Dispatch(context.Background(), req, nil, nil, nil, nil, dispatchCfg(true)) @@ -90,7 +90,7 @@ func TestDispatch_AggWithoutGroupBy_FallsThrough(t *testing.T) { req := bareReq() req.Agg = &measurev1.QueryRequest_Aggregation{ Function: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM, - FieldName: "value", + FieldName: fieldValue, } _, _, handled, err := Dispatch(context.Background(), req, nil, nil, nil, nil, dispatchCfg(true)) @@ -118,16 +118,16 @@ func TestDispatch_GroupByAggUncoveredProjection_FallsThrough(t *testing.T) { { name: "groupby_tag_not_in_projection", mutate: func(req *measurev1.QueryRequest) { - // GroupBy references "region" but TagProjection only carries "svc". + // GroupBy references region but TagProjection only carries svc. req.GroupBy = &measurev1.QueryRequest_GroupBy{ TagProjection: &modelv1.TagProjection{TagFamilies: []*modelv1.TagProjection_TagFamily{ {Name: "default", Tags: []string{"region"}}, }}, - FieldName: "value", + FieldName: fieldValue, } req.Agg = &measurev1.QueryRequest_Aggregation{ Function: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM, - FieldName: "value", + FieldName: fieldValue, } }, }, @@ -136,13 +136,13 @@ func TestDispatch_GroupByAggUncoveredProjection_FallsThrough(t *testing.T) { mutate: func(req *measurev1.QueryRequest) { req.GroupBy = &measurev1.QueryRequest_GroupBy{ TagProjection: projTagProj(), - FieldName: "value", + FieldName: fieldValue, } req.Agg = &measurev1.QueryRequest_Aggregation{ Function: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM, - FieldName: "value", + FieldName: fieldValue, } - // Strip "value" from FieldProjection so the Agg field is uncovered. + // Strip the value field from FieldProjection so the Agg field is uncovered. req.FieldProjection = nil }, }, @@ -182,7 +182,7 @@ func TestDispatch_Top_ReachesEcQuery(t *testing.T) { req := bareReq() req.Top = &measurev1.QueryRequest_Top{ Number: 5, - FieldName: "value", + FieldName: fieldValue, FieldValueSort: modelv1.Sort_SORT_DESC, } @@ -351,11 +351,14 @@ func TestDispatch_TagValidatedBeforeField(t *testing.T) { {Name: "default", Tags: []string{"ghost"}}, }} req.FieldProjection = &measurev1.QueryRequest_FieldProjection{Names: []string{"phantom"}} - _, _, _, err := Dispatch(context.Background(), + _, _, handled, err := Dispatch(context.Background(), req, metadata, measureSchema, logicalSchema, ec, dispatchCfg(true)) if err == nil || err.Error() != "ghost: tag is not defined" { t.Fatalf("tag error must take precedence over field error; got %v", err) } + if !handled { + t.Fatal("projection parity error must report handled=true (caller must not retry row path)") + } } // TestDispatch_NoTimeRange_EmptyResultParity covers G9c #9: a nil @@ -489,7 +492,7 @@ func TestDispatch_Counters_TrackFellThroughCalls(t *testing.T) { // schema/ec/metadata in the loop below). The counter is still // exercised on the clean (non-error) fall-through path. gbReq := bareReq() - gbReq.GroupBy = &measurev1.QueryRequest_GroupBy{TagProjection: projTagProj(), FieldName: "value"} + gbReq.GroupBy = &measurev1.QueryRequest_GroupBy{TagProjection: projTagProj(), FieldName: fieldValue} noTimeReq := bareReq() noTimeReq.TimeRange = nil @@ -531,11 +534,11 @@ func TestDispatch_GroupByAggCovered_ReachesEcQuery(t *testing.T) { req := bareReq() req.GroupBy = &measurev1.QueryRequest_GroupBy{ TagProjection: projTagProj(), - FieldName: "value", + FieldName: fieldValue, } req.Agg = &measurev1.QueryRequest_Aggregation{ Function: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM, - FieldName: "value", + FieldName: fieldValue, } iter, planStr, handled, err := Dispatch(context.Background(), @@ -568,14 +571,14 @@ func TestAugmentRequestWithHiddenTags_AppendsFamiliesAfterVisible(t *testing.T) t.Fatal("augment must return a clone when extras are present") } if len(req.GetTagProjection().GetTagFamilies()) != 1 || - req.GetTagProjection().GetTagFamilies()[0].GetTags()[0] != "svc" { + req.GetTagProjection().GetTagFamilies()[0].GetTags()[0] != tagSvc { t.Fatalf("caller's req.TagProjection must be untouched, got %+v", req.GetTagProjection()) } fams := got.GetTagProjection().GetTagFamilies() if len(fams) != 3 { t.Fatalf("want 3 families (1 visible + 2 hidden), got %d: %+v", len(fams), fams) } - if fams[0].GetName() != "default" || fams[0].GetTags()[0] != "svc" { + if fams[0].GetName() != "default" || fams[0].GetTags()[0] != tagSvc { t.Fatalf("visible family must stay first, got %+v", fams[0]) } if fams[1].GetName() != "default" || fams[1].GetTags()[0] != "region" { @@ -600,7 +603,7 @@ func TestHiddenTagsMIterator_StripsHiddenTagsFromCurrent(t *testing.T) { TagFamilies: []*modelv1.TagFamily{{ Name: "default", Tags: []*modelv1.Tag{ - {Key: "svc", Value: &modelv1.TagValue{Value: &modelv1.TagValue_Str{Str: &modelv1.Str{Value: "a"}}}}, + {Key: tagSvc, Value: &modelv1.TagValue{Value: &modelv1.TagValue_Str{Str: &modelv1.Str{Value: "a"}}}}, {Key: "region", Value: &modelv1.TagValue{Value: &modelv1.TagValue_Str{Str: &modelv1.Str{Value: "us"}}}}, }, }}, @@ -618,7 +621,7 @@ func TestHiddenTagsMIterator_StripsHiddenTagsFromCurrent(t *testing.T) { t.Fatalf("expected one family after strip, got %+v", cur) } tags := cur[0].DataPoint.TagFamilies[0].Tags - if len(tags) != 1 || tags[0].Key != "svc" { + if len(tags) != 1 || tags[0].Key != tagSvc { t.Fatalf("only visible tag 'svc' must remain, got %+v", tags) } if it.Close() != nil { diff --git a/pkg/query/vectorized/measure/plan/executor_test.go b/pkg/query/vectorized/measure/plan/executor_test.go index cfce60e0f..dbedf6ea1 100644 --- a/pkg/query/vectorized/measure/plan/executor_test.go +++ b/pkg/query/vectorized/measure/plan/executor_test.go @@ -78,8 +78,8 @@ func TestExecute_GroupByAgg_EmitsAggregatedRowsWithNilTimestamp(t *testing.T) { scan := NewScan(schema, ScanParams{}) scan.Source = src gba, err := NewGroupByAgg(scan, - &model.MeasureGroupBy{TagFamily: "default", TagNames: []string{"svc"}}, - &model.MeasureAgg{FieldName: "value", Func: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM}, + &model.MeasureGroupBy{TagFamily: "default", TagNames: []string{tagSvc}}, + &model.MeasureAgg{FieldName: fieldValue, Func: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM}, ) if err != nil { t.Fatalf("NewGroupByAgg: %v", err) @@ -106,11 +106,11 @@ func TestExecute_GroupByAgg_EmitsAggregatedRowsWithNilTimestamp(t *testing.T) { t.Fatalf("want one TagFamily 'default', got %+v", idp.DataPoint.TagFamilies) } tags := idp.DataPoint.TagFamilies[0].Tags - if len(tags) != 1 || tags[0].Key != "svc" { + if len(tags) != 1 || tags[0].Key != tagSvc { t.Fatalf("want one Tag 'svc', got %+v", tags) } svc := tags[0].Value.GetStr().GetValue() - if len(idp.DataPoint.Fields) != 1 || idp.DataPoint.Fields[0].Name != "value" { + if len(idp.DataPoint.Fields) != 1 || idp.DataPoint.Fields[0].Name != fieldValue { t.Fatalf("want one Field 'value' (row-path parity), got %+v", idp.DataPoint.Fields) } bySvc[svc] = idp.DataPoint.Fields[0].Value.GetInt().GetValue() @@ -133,7 +133,7 @@ func TestExecute_ScalarReduce_EmitsSingleRow(t *testing.T) { scan := NewScan(schema, ScanParams{}) scan.Source = src gba, err := NewGroupByAgg(scan, nil, - &model.MeasureAgg{FieldName: "value", Func: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM}, + &model.MeasureAgg{FieldName: fieldValue, Func: modelv1.AggregationFunction_AGGREGATION_FUNCTION_SUM}, ) if err != nil { t.Fatalf("NewGroupByAgg: %v", err) @@ -160,7 +160,7 @@ func TestExecute_ScalarReduce_EmitsSingleRow(t *testing.T) { } tags := idp.DataPoint.TagFamilies[0].Tags svc = tags[0].Value.GetStr().GetValue() - if len(idp.DataPoint.Fields) != 1 || idp.DataPoint.Fields[0].Name != "value" { + if len(idp.DataPoint.Fields) != 1 || idp.DataPoint.Fields[0].Name != fieldValue { t.Fatalf("want one Field 'value', got %+v", idp.DataPoint.Fields) } sum = idp.DataPoint.Fields[0].Value.GetInt().GetValue() @@ -188,7 +188,7 @@ func TestExecute_RawGroupBy_EmitsFirstRowPerGroup(t *testing.T) { scan := NewScan(schema, ScanParams{}) scan.Source = src gba, err := NewGroupByAgg(scan, - &model.MeasureGroupBy{TagFamily: "default", TagNames: []string{"svc"}}, nil, + &model.MeasureGroupBy{TagFamily: "default", TagNames: []string{tagSvc}}, nil, ) if err != nil { t.Fatalf("NewGroupByAgg: %v", err) @@ -215,7 +215,7 @@ func TestExecute_RawGroupBy_EmitsFirstRowPerGroup(t *testing.T) { idp := dps[0] // Raw GroupBy preserves the input schema, so the field column // survives (unlike the aggregation shapes). - if len(idp.DataPoint.Fields) != 1 || idp.DataPoint.Fields[0].Name != "value" { + if len(idp.DataPoint.Fields) != 1 || idp.DataPoint.Fields[0].Name != fieldValue { t.Fatalf("raw GroupBy must preserve the field column, got %+v", idp.DataPoint.Fields) } svc := idp.DataPoint.TagFamilies[0].Tags[0].Value.GetStr().GetValue()
