mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore/Table: Keep existing field types if possible (#24944)
* Explore/Table: Keep existing field types if possible
This commit is contained in:
parent
83d933d010
commit
f5a9b23d83
@ -26,12 +26,12 @@ import { getFieldDisplayName } from '../field/fieldState';
|
||||
|
||||
function convertTableToDataFrame(table: TableData): DataFrame {
|
||||
const fields = table.columns.map(c => {
|
||||
const { text, ...disp } = c;
|
||||
const { text, type, ...disp } = c as any;
|
||||
return {
|
||||
name: text, // rename 'text' to the 'name' field
|
||||
config: (disp || {}) as FieldConfig,
|
||||
values: new ArrayVector(),
|
||||
type: FieldType.other,
|
||||
type: type && Object.values(FieldType).includes(type as FieldType) ? (type as FieldType) : FieldType.other,
|
||||
};
|
||||
});
|
||||
|
||||
@ -46,9 +46,11 @@ function convertTableToDataFrame(table: TableData): DataFrame {
|
||||
}
|
||||
|
||||
for (const f of fields) {
|
||||
const t = guessFieldTypeForField(f);
|
||||
if (t) {
|
||||
f.type = t;
|
||||
if (f.type === FieldType.other) {
|
||||
const t = guessFieldTypeForField(f);
|
||||
if (t) {
|
||||
f.type = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user