Commit 31e7e35b by lzd Committed by David

Datasource/Elasticsearch: Fix logs which were displayed with incorrect timestamp…

Datasource/Elasticsearch: Fix logs which were displayed with incorrect timestamp in Explore logs tab (#20009)
parent 92ab4d80
...@@ -57,6 +57,16 @@ describe('Apending DataFrame', () => { ...@@ -57,6 +57,16 @@ describe('Apending DataFrame', () => {
{ time: null, name: null, value: null, value2: 'XXX' }, // 4 { time: null, name: null, value: null, value2: 'XXX' }, // 4
]); ]);
// Add a time value that has an array type
frame.add({ time: [300] });
expect(frame.toArray()).toEqual([
{ time: 100, name: 'a', value: 1, value2: null }, // 1
{ time: 200, name: 'BB', value: 20, value2: null }, // 2
{ time: null, name: null, value: 3, value2: null }, // 3
{ time: null, name: null, value: null, value2: 'XXX' }, // 4
{ time: 300, name: null, value: null, value2: null }, // 5
]);
// Make sure length survives a spread operator // Make sure length survives a spread operator
const keys = Object.keys(frame); const keys = Object.keys(frame);
const copy = { ...frame } as any; const copy = { ...frame } as any;
......
...@@ -234,6 +234,11 @@ export class MutableDataFrame<T = any> implements DataFrame, MutableVector<T> { ...@@ -234,6 +234,11 @@ export class MutableDataFrame<T = any> implements DataFrame, MutableVector<T> {
field.parse = makeFieldParser(val, field); field.parse = makeFieldParser(val, field);
} }
val = field.parse(val); val = field.parse(val);
} else if (field.type === FieldType.time && isArray(val)) {
if (!field.parse) {
field.parse = (val: any[]) => val[0] || undefined;
}
val = field.parse(val);
} }
if (val === undefined) { if (val === undefined) {
......
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