Commit bbff282b by Ryan McKinley Committed by GitHub

GEL: wrap arrow utils in async load (#20134)

parent 2d7d171e
...@@ -10,10 +10,9 @@ import { ExpressionQueryEditor } from './ExpressionQueryEditor'; ...@@ -10,10 +10,9 @@ import { ExpressionQueryEditor } from './ExpressionQueryEditor';
import { Observable, from } from 'rxjs'; import { Observable, from } from 'rxjs';
import { config } from '@grafana/runtime'; import { config } from '@grafana/runtime';
import { getBackendSrv } from 'app/core/services/backend_srv'; import { getBackendSrv } from 'app/core/services/backend_srv';
import { gelResponseToDataFrames } from './util';
/** /**
* This is a singleton that is not actually instanciated * This is a singleton that is not actually instantiated
*/ */
export class ExpressionDatasourceApi extends DataSourceApi<ExpressionQuery> { export class ExpressionDatasourceApi extends DataSourceApi<ExpressionQuery> {
constructor(instanceSettings: DataSourceInstanceSettings) { constructor(instanceSettings: DataSourceInstanceSettings) {
...@@ -53,11 +52,19 @@ export class ExpressionDatasourceApi extends DataSourceApi<ExpressionQuery> { ...@@ -53,11 +52,19 @@ export class ExpressionDatasourceApi extends DataSourceApi<ExpressionQuery> {
queries: queries, queries: queries,
}) })
.then((rsp: any) => { .then((rsp: any) => {
return { data: gelResponseToDataFrames(rsp) } as DataQueryResponse; return this.toDataQueryResponse(rsp);
}); });
return from(req); return from(req);
} }
/**
* This makes the arrow libary loading async.
*/
async toDataQueryResponse(rsp: any): Promise<DataQueryResponse> {
const { gelResponseToDataFrames } = await import(/* webpackChunkName: "apache-arrow-util" */ './util');
return { data: gelResponseToDataFrames(rsp) };
}
testDatasource() { testDatasource() {
return Promise.resolve({}); return Promise.resolve({});
} }
......
import { DataFrame, FieldType, Field, Vector } from '@grafana/data'; import { DataFrame, FieldType, Field, Vector } from '@grafana/data';
import { Table, ArrowType } from 'apache-arrow'; import { Table, ArrowType } from 'apache-arrow';
export function base64StringToArrowTable(text: string) { export function base64StringToArrowTable(text: string): Table {
const b64 = atob(text); const b64 = atob(text);
const arr = Uint8Array.from(b64, c => { const arr = Uint8Array.from(b64, c => {
return c.charCodeAt(0); return c.charCodeAt(0);
......
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