ArrowDataFrame: allow empty results (#22524)

This commit is contained in:
Ryan McKinley
2020-03-02 23:56:01 -08:00
committed by GitHub
parent baa356e26d
commit f09ee3d8c2
2 changed files with 13 additions and 3 deletions
@@ -37,6 +37,13 @@ describe('GEL Utils', () => {
const norm = frames.map(f => toDataFrameDTO(f));
expect(norm).toMatchSnapshot();
});
test('processEmptyResults', () => {
const frames = resultsToDataFrames({
results: { '': { refId: '', meta: null, series: null, tables: null, dataframes: null } },
});
expect(frames.length).toEqual(0);
});
});
describe('Read/Write arrow Table to DataFrame', () => {
@@ -146,9 +146,12 @@ export function grafanaDataFrameToArrowTable(data: DataFrame): Table {
export function resultsToDataFrames(rsp: any): DataFrame[] {
const frames: DataFrame[] = [];
for (const res of Object.values(rsp.results)) {
for (const b of (res as any).dataframes) {
const t = base64StringToArrowTable(b as string);
frames.push(arrowTableToDataFrame(t));
const r = res as any;
if (r.dataframes) {
for (const b of r.dataframes) {
const t = base64StringToArrowTable(b as string);
frames.push(arrowTableToDataFrame(t));
}
}
}
return frames;