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'; ...@@ -26,12 +26,12 @@ import { getFieldDisplayName } from '../field/fieldState';
function convertTableToDataFrame(table: TableData): DataFrame { function convertTableToDataFrame(table: TableData): DataFrame {
const fields = table.columns.map(c => { const fields = table.columns.map(c => {
const { text, ...disp } = c; const { text, type, ...disp } = c as any;
return { return {
name: text, // rename 'text' to the 'name' field name: text, // rename 'text' to the 'name' field
config: (disp || {}) as FieldConfig, config: (disp || {}) as FieldConfig,
values: new ArrayVector(), 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 { ...@@ -46,9 +46,11 @@ function convertTableToDataFrame(table: TableData): DataFrame {
} }
for (const f of fields) { for (const f of fields) {
const t = guessFieldTypeForField(f); if (f.type === FieldType.other) {
if (t) { const t = guessFieldTypeForField(f);
f.type = t; if (t) {
f.type = t;
}
} }
} }
......
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