Commit 95d53f03 by Torkel Ödegaard Committed by GitHub

Explore: Use merge transform instead of DataFrame -> Table -> Merge -> toDataFrame (#25694)

parent eb734a2f
...@@ -4,13 +4,12 @@ import { ...@@ -4,13 +4,12 @@ import {
DataFrame, DataFrame,
FieldType, FieldType,
TimeZone, TimeZone,
toDataFrame,
getDisplayProcessor, getDisplayProcessor,
ExploreMode, ExploreMode,
PreferredVisualisationType, PreferredVisualisationType,
standardTransformers,
} from '@grafana/data'; } from '@grafana/data';
import { ExploreItemState } from 'app/types/explore'; import { ExploreItemState } from 'app/types/explore';
import TableModel, { mergeTablesIntoModel, MutableColumn } from 'app/core/table_model';
import { sortLogsResult, refreshIntervalToSortOrder } from 'app/core/utils/explore'; import { sortLogsResult, refreshIntervalToSortOrder } from 'app/core/utils/explore';
import { dataFrameToLogsModel } from 'app/core/logs_model'; import { dataFrameToLogsModel } from 'app/core/logs_model';
import { getGraphSeriesModel } from 'app/plugins/panel/graph2/getGraphSeriesModel'; import { getGraphSeriesModel } from 'app/plugins/panel/graph2/getGraphSeriesModel';
...@@ -69,36 +68,8 @@ export class ResultProcessor { ...@@ -69,36 +68,8 @@ export class ResultProcessor {
return null; return null;
} }
const tables = onlyTables.map(frame => { const mergeTransformer = standardTransformers.mergeTransformer.transformer({});
const { fields } = frame; const data = mergeTransformer(onlyTables)[0];
const fieldCount = fields.length;
const rowCount = frame.length;
const columns: MutableColumn[] = fields.map(field => ({
text: field.name,
type: field.type,
filterable: field.config.filterable,
custom: field.config.custom,
}));
const rows: any[][] = [];
for (let i = 0; i < rowCount; i++) {
const row: any[] = [];
for (let j = 0; j < fieldCount; j++) {
row.push(frame.fields[j].values.get(i));
}
rows.push(row);
}
return new TableModel({
columns,
rows,
meta: frame.meta,
});
});
const mergedTable = mergeTablesIntoModel(new TableModel(), ...tables);
const data = toDataFrame(mergedTable);
// set display processor // set display processor
for (const field of data.fields) { for (const field of data.fields) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment