From 0896ed9da9fc3ee252fe521d701587ade970c528 Mon Sep 17 00:00:00 2001 From: ahrefabhi Date: Thu, 4 Sep 2025 18:23:14 +0530 Subject: [PATCH] fix: added fix for order by in trace opeartor --- .../TracesExplorer/ListView/index.tsx | 10 ++++++++++ frontend/src/pages/TracesExplorer/index.tsx | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/frontend/src/container/TracesExplorer/ListView/index.tsx b/frontend/src/container/TracesExplorer/ListView/index.tsx index d47fce21cf..feb5d67dfa 100644 --- a/frontend/src/container/TracesExplorer/ListView/index.tsx +++ b/frontend/src/container/TracesExplorer/ListView/index.tsx @@ -106,6 +106,16 @@ function ListView({ ]; } + // add order by to trace operator + if (query.builder.queryTraceOperator.length > 0) { + query.builder.queryTraceOperator[0].orderBy = [ + { + columnName: orderBy.split(':')[0], + order: orderBy.split(':')[1] as 'asc' | 'desc', + }, + ]; + } + return query; }, [stagedQuery, orderBy]); diff --git a/frontend/src/pages/TracesExplorer/index.tsx b/frontend/src/pages/TracesExplorer/index.tsx index 3feb83a1d0..3a6f4fed1e 100644 --- a/frontend/src/pages/TracesExplorer/index.tsx +++ b/frontend/src/pages/TracesExplorer/index.tsx @@ -102,7 +102,15 @@ function TracesExplorer(): JSX.Element { handleSetConfig(PANEL_TYPES.LIST, DataSource.TRACES); } - // TODO: remove formula when switching to List view + if ( + (selectedView === ExplorerViews.TRACE || + selectedView === ExplorerViews.LIST) && + stagedQuery?.builder?.queryTraceOperator && + stagedQuery.builder.queryTraceOperator.length > 0 + ) { + // remove order by from trace operator + stagedQuery.builder.queryTraceOperator[0].orderBy = []; + } setSelectedView(view); @@ -110,7 +118,13 @@ function TracesExplorer(): JSX.Element { view === ExplorerViews.TIMESERIES ? PANEL_TYPES.TIME_SERIES : view, ); }, - [handleSetConfig, handleExplorerTabChange, selectedView, setSelectedView], + [ + handleSetConfig, + handleExplorerTabChange, + selectedView, + setSelectedView, + stagedQuery, + ], ); const listQuery = useMemo(() => {