diff --git a/src/datasources/data-frame/DataFrameDataSource.test.ts b/src/datasources/data-frame/DataFrameDataSource.test.ts index 1277938..15836a7 100644 --- a/src/datasources/data-frame/DataFrameDataSource.test.ts +++ b/src/datasources/data-frame/DataFrameDataSource.test.ts @@ -243,8 +243,8 @@ it('returns table properties for metadata query', async () => { expect(fetchMock).toHaveBeenCalledWith(expect.objectContaining({ url: '_/nidataframe/v1/tables/1' })); expect(response.data[0].fields).toEqual([ - { name: 'name', values: ['hello', 'foo'] }, - { name: 'value', values: ['world', 'bar'] }, + { name: 'hello', values: ['world'] }, + { name: 'foo', values: ['bar'] }, ]) }); @@ -253,12 +253,8 @@ it('handles metadata query when table has no properties', async () => { const response = await ds.query(query); - console.log(fetchMock.mock.calls) expect(fetchMock).toHaveBeenCalledWith(expect.objectContaining({ url: '_/nidataframe/v1/tables/2' })); - expect(response.data[0].fields).toEqual([ - { name: 'name', values: [] }, - { name: 'value', values: [] }, - ]) + expect(response.data[0].fields).toEqual([]); }); const buildQuery = (targets: DataFrameQuery[]): DataQueryRequest => { diff --git a/src/datasources/data-frame/DataFrameDataSource.ts b/src/datasources/data-frame/DataFrameDataSource.ts index 2cee8a4..e44d8eb 100644 --- a/src/datasources/data-frame/DataFrameDataSource.ts +++ b/src/datasources/data-frame/DataFrameDataSource.ts @@ -44,10 +44,7 @@ export class DataFrameDataSource extends DataSourceBase { return { refId: processedQuery.refId, name: metadata.name, - fields: [ - { name: 'name', values: Object.keys(metadata.properties) }, - { name: 'value', values: Object.values(metadata.properties) }, - ], + fields: Object.entries(metadata.properties).map(([name, value]) => ({ name, values: [value] })), }; } else { const columns = this.getColumnTypes(processedQuery.columns, metadata?.columns ?? []);