From 6ed78e8a4d5aa91cdd3c14d155b8036ca9454b3f Mon Sep 17 00:00:00 2001 From: SagarRajput-7 Date: Tue, 15 Jul 2025 14:08:45 +0530 Subject: [PATCH] feat: fixed reduceTo not working --- .../api/v5/queryRange/prepareQueryRangePayloadV5.ts | 10 ++++++---- frontend/src/container/GridTableComponent/utils.ts | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/api/v5/queryRange/prepareQueryRangePayloadV5.ts b/frontend/src/api/v5/queryRange/prepareQueryRangePayloadV5.ts index d3b97aadaa17..435683e584b7 100644 --- a/frontend/src/api/v5/queryRange/prepareQueryRangePayloadV5.ts +++ b/frontend/src/api/v5/queryRange/prepareQueryRangePayloadV5.ts @@ -163,6 +163,7 @@ export function parseAggregations( export function createAggregation( queryData: any, + panelType?: PANEL_TYPES, ): TraceAggregation[] | LogAggregation[] | MetricAggregation[] { if (!queryData) { return []; @@ -170,9 +171,10 @@ export function createAggregation( const haveReduceTo = queryData.dataSource === DataSource.METRICS && - (queryData.panelType === PANEL_TYPES.TABLE || - queryData.panelType === PANEL_TYPES.PIE || - queryData.panelType === PANEL_TYPES.VALUE); + panelType && + (panelType === PANEL_TYPES.TABLE || + panelType === PANEL_TYPES.PIE || + panelType === PANEL_TYPES.VALUE); if (queryData.dataSource === DataSource.METRICS) { return [ @@ -219,7 +221,7 @@ function convertBuilderQueriesToV5( const baseSpec = createBaseSpec(queryData, requestType, panelType); let spec: QueryEnvelope['spec']; - const aggregations = createAggregation(queryData); + const aggregations = createAggregation(queryData, panelType); switch (signal) { case 'traces': diff --git a/frontend/src/container/GridTableComponent/utils.ts b/frontend/src/container/GridTableComponent/utils.ts index b6260eb2751b..cf42e199b856 100644 --- a/frontend/src/container/GridTableComponent/utils.ts +++ b/frontend/src/container/GridTableComponent/utils.ts @@ -1,6 +1,7 @@ /* eslint-disable sonarjs/cognitive-complexity */ import { ColumnsType, ColumnType } from 'antd/es/table'; import { createAggregation } from 'api/v5/queryRange/prepareQueryRangePayloadV5'; +import { PANEL_TYPES } from 'constants/queryBuilder'; import { convertUnit } from 'container/NewWidget/RightContainer/dataFormatCategories'; import { ThresholdProps } from 'container/NewWidget/RightContainer/Threshold/types'; import { QUERY_TABLE_CONFIG } from 'container/QueryTable/config'; @@ -191,6 +192,7 @@ export function createColumnsAndDataSource( (query) => query.queryName === item.queryName, ) : undefined, + PANEL_TYPES.TABLE, )?.length > 1; const column: ColumnType = {