diff --git a/pkg/query-service/app/queryBuilder/query_builder.go b/pkg/query-service/app/queryBuilder/query_builder.go index e824c15ac3..9b5be469af 100644 --- a/pkg/query-service/app/queryBuilder/query_builder.go +++ b/pkg/query-service/app/queryBuilder/query_builder.go @@ -441,6 +441,9 @@ func (c *cacheKeyGenerator) GenerateKeys(params *v3.QueryRangeParamsV3) map[stri // Build keys for each expression for _, query := range params.CompositeQuery.BuilderQueries { if query.Expression != query.QueryName { + if params.Version != "v4" && params.CompositeQuery.PanelType != v3.PanelTypeGraph { + continue + } expression, _ := govaluate.NewEvaluableExpressionWithFunctions(query.Expression, EvalFuncs) if !isMetricExpression(expression, params) && !isLogExpression(expression, params) { diff --git a/pkg/query-service/app/queryBuilder/query_builder_test.go b/pkg/query-service/app/queryBuilder/query_builder_test.go index eba5a56868..36365060c3 100644 --- a/pkg/query-service/app/queryBuilder/query_builder_test.go +++ b/pkg/query-service/app/queryBuilder/query_builder_test.go @@ -1206,6 +1206,87 @@ func TestGenerateCacheKeysMetricsBuilder(t *testing.T) { "A": "source=metrics&step=60&aggregate=sum_rate&timeAggregation=&spaceAggregation=&aggregateAttribute=signoz_latency_bucket---false&filter-0=key:service_name---false,op:=,value:A&groupBy-0=service_name---false&groupBy-1=le---false&having-0=column:value,op:>,value:100", }, }, + { + name: "version=v3;panelType=value;dataSource=metrics;queryType=builder with expression", //not caching panel type value for v3 + query: &v3.QueryRangeParamsV3{ + Version: "v3", + CompositeQuery: &v3.CompositeQuery{ + QueryType: v3.QueryTypeBuilder, + PanelType: v3.PanelTypeValue, + FillGaps: false, + BuilderQueries: map[string]*v3.BuilderQuery{ + "A": { + QueryName: "A", + DataSource: v3.DataSourceMetrics, + AggregateOperator: v3.AggregateOperatorNoOp, + AggregateAttribute: v3.AttributeKey{ + Key: "system_memory_usage", + DataType: v3.AttributeKeyDataTypeFloat64, + Type: v3.AttributeKeyType("Gauge"), + IsColumn: true, + }, + TimeAggregation: v3.TimeAggregationUnspecified, + SpaceAggregation: v3.SpaceAggregationSum, + Filters: &v3.FilterSet{ + Operator: "AND", + Items: []v3.FilterItem{ + { + Key: v3.AttributeKey{ + Key: "state", + DataType: v3.AttributeKeyDataTypeString, + Type: v3.AttributeKeyTypeTag, + IsColumn: false, + }, + Operator: v3.FilterOperatorEqual, + Value: "cached", + }, + }, + }, + Expression: "A", + Disabled: true, + StepInterval: 60, + }, + "B": { + QueryName: "B", + DataSource: v3.DataSourceMetrics, + AggregateOperator: v3.AggregateOperatorNoOp, + AggregateAttribute: v3.AttributeKey{ + Key: "system_memory_usage", + DataType: v3.AttributeKeyDataTypeFloat64, + Type: v3.AttributeKeyType("Gauge"), + IsColumn: true, + }, + TimeAggregation: v3.TimeAggregationUnspecified, + SpaceAggregation: v3.SpaceAggregationSum, + Filters: &v3.FilterSet{ + Operator: "AND", + Items: []v3.FilterItem{ + { + Key: v3.AttributeKey{ + Key: "state", + DataType: v3.AttributeKeyDataTypeString, + Type: v3.AttributeKeyTypeTag, + IsColumn: false, + }, + Operator: v3.FilterOperatorEqual, + Value: "cached", + }, + }, + }, + Expression: "B", + Disabled: true, + StepInterval: 60, + }, + "F1": { + QueryName: "F1", + Expression: "A+B", + Disabled: false, + }, + }, + }, + }, + expectedCacheKeys: map[string]string{}, + }, { name: "version=v4;panelType=table;dataSource=metrics;queryType=builder", query: &v3.QueryRangeParamsV3{