Commit f5a9b23d by kay delaney Committed by GitHub

Explore/Table: Keep existing field types if possible (#24944)

* Explore/Table: Keep existing field types if possible
parent 83d933d0
......@@ -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,11 +46,13 @@ function convertTableToDataFrame(table: TableData): DataFrame {
}
for (const f of fields) {
if (f.type === FieldType.other) {
const t = guessFieldTypeForField(f);
if (t) {
f.type = t;
}
}
}
return {
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