From a01b4c31a1fe358420095e0278b10437e8425e8a Mon Sep 17 00:00:00 2001 From: Kristina Date: Thu, 10 Jul 2025 18:47:18 -0500 Subject: [PATCH] Transformations: Allow queries without dataframe results to be selectable as filters (#107152) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add mention of external type to correlations docs * 🆗 * Merge request targets in with results * Ensure we do not mutate result set --- .../TransformationOperationRow.tsx | 12 +++++++++++- .../TransformationsEditor/TransformationsEditor.tsx | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/components/TransformationsEditor/TransformationOperationRow.tsx b/public/app/features/dashboard/components/TransformationsEditor/TransformationOperationRow.tsx index b77e0f41620..bebae5de3e2 100644 --- a/public/app/features/dashboard/components/TransformationsEditor/TransformationOperationRow.tsx +++ b/public/app/features/dashboard/components/TransformationsEditor/TransformationOperationRow.tsx @@ -138,7 +138,17 @@ export const TransformationOperationRow = ({ .subscribe(setOutput); const prevOutputSubscription = transformDataFrame(prevInputTransforms, data.series, ctx) .pipe(mergeMap((before) => transformDataFrame(prevOutputTransforms, before, ctx))) - .subscribe(setPrevOutput); + .subscribe((result) => { + let mergedResult = [...result]; + // add refIds that were requested even if they did not return a result + data.request?.targets.forEach((series) => { + const refIdInResult = mergedResult.some((frame) => frame.refId === series.refId); + if (!refIdInResult) { + mergedResult.push({ refId: series.refId, fields: [], length: 0 }); + } + }); + setPrevOutput(mergedResult); + }); return function unsubscribe() { inputSubscription.unsubscribe(); diff --git a/public/app/features/dashboard/components/TransformationsEditor/TransformationsEditor.tsx b/public/app/features/dashboard/components/TransformationsEditor/TransformationsEditor.tsx index 17d18efba74..afdf6b782ea 100644 --- a/public/app/features/dashboard/components/TransformationsEditor/TransformationsEditor.tsx +++ b/public/app/features/dashboard/components/TransformationsEditor/TransformationsEditor.tsx @@ -5,6 +5,7 @@ import { Unsubscribable } from 'rxjs'; import { DataFrame, + DataQueryRequest, DataTransformerConfig, PanelData, SelectableValue, @@ -44,6 +45,7 @@ export type viewAllType = 'viewAll'; export type FilterCategory = TransformerCategory | viewAllType; export interface TransformationData { + request?: DataQueryRequest; series: DataFrame[]; annotations?: DataFrame[]; }