mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataFrame processing: Require table rows to be array (#20357)
This commit is contained in:
parent
17fe704ae8
commit
4260cd548f
@ -59,6 +59,15 @@ describe('toDataFrame', () => {
|
||||
expect(again).toBe(input);
|
||||
});
|
||||
|
||||
it('throws when table rows is not array', () => {
|
||||
expect(() =>
|
||||
toDataFrame({
|
||||
columns: [],
|
||||
rows: {},
|
||||
})
|
||||
).toThrowError('Expected table rows to be array, got object.');
|
||||
});
|
||||
|
||||
it('migrate from 6.3 style rows', () => {
|
||||
const oldDataFrame = {
|
||||
fields: [{ name: 'A' }, { name: 'B' }, { name: 'C' }],
|
||||
|
@ -1,7 +1,5 @@
|
||||
// Libraries
|
||||
import isNumber from 'lodash/isNumber';
|
||||
import isString from 'lodash/isString';
|
||||
import isBoolean from 'lodash/isBoolean';
|
||||
import { isArray, isBoolean, isNumber, isString } from 'lodash';
|
||||
|
||||
// Types
|
||||
import {
|
||||
@ -34,6 +32,10 @@ function convertTableToDataFrame(table: TableData): DataFrame {
|
||||
};
|
||||
});
|
||||
|
||||
if (!isArray(table.rows)) {
|
||||
throw new Error(`Expected table rows to be array, got ${typeof table.rows}.`);
|
||||
}
|
||||
|
||||
for (const row of table.rows) {
|
||||
for (let i = 0; i < fields.length; i++) {
|
||||
fields[i].values.buffer.push(row[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user