Skip to content

Commit

Permalink
add dataSourceId to dataSet (opensearch-project#7361)
Browse files Browse the repository at this point in the history
* add dataSourceId to dataSet

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* fix tests

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

---------

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
  • Loading branch information
ruanyl authored Jul 23, 2024
1 parent 4f094a8 commit 3587291
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/plugins/data/public/data_sources/datasource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { DataSource } from './datasource';
export interface IndexPatternOption {
title: string;
id: string;
dataSourceId?: string;
}

export interface IDataSourceGroup {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ describe('DefaultDslDataSource', () => {

it('should return a populated dataset if getCache returns non-empty array', async () => {
const mockSavedObjects = [
{ id: '1', attributes: { title: 'Index1' } },
{ id: '2', attributes: { title: 'Index2' } },
{ id: '1', attributes: { title: 'Index1' }, references: [] },
{ id: '2', attributes: { title: 'Index2' }, references: [] },
];
indexPatternsMock.getCache.mockResolvedValue(mockSavedObjects);
const dataSource = new DefaultDslDataSource({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { getDataSourceReference } from '../../../common/index_patterns/utils';
import { SavedObject } from '../../../../../core/public';
import {
IndexPatternSavedObjectAttrs,
Expand Down Expand Up @@ -54,6 +55,7 @@ export class DefaultDslDataSource extends DataSource<
return {
id: savedObject.id,
title: savedObject.attributes.title,
dataSourceId: getDataSourceReference(savedObject.references)?.id,
};
}),
};
Expand Down

0 comments on commit 3587291

Please sign in to comment.