Skip to content

Commit

Permalink
[discover][bug] configurator dataset issue (#7981) (#7982)
Browse files Browse the repository at this point in the history
* [discover][bug] configurator dataset issue

bad rebase caused only conflict was the dataset.



* fix test



* fix connections



---------


(cherry picked from commit 7dedc58)

Signed-off-by: Kawika Avilla <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent d3ce40f commit 999bc05
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ describe('indexPatternTypeConfig', () => {
dataSource: { id: 'dataSourceId', title: 'Cluster 1', type: 'OpenSearch' },
};
expect(indexPatternTypeConfig.supportedLanguages(mockDataset)).toEqual([
'DQL',
'Lucene',
'kuery',
'lucene',
'PPL',
'SQL',
]);

mockDataset.dataSource = { ...mockDataset.dataSource!, type: 'other' };
expect(indexPatternTypeConfig.supportedLanguages(mockDataset)).toEqual([
'DQL',
'Lucene',
'kuery',
'lucene',
'PPL',
'SQL',
]);
Expand Down
15 changes: 10 additions & 5 deletions src/plugins/data/public/ui/dataset_selector/configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export const Configurator = ({
const type = queryString.getDatasetService().getType(baseDataset.type);
const languages = type?.supportedLanguages(baseDataset) || [];

const [dataset, setDataset] = useState<Dataset>(baseDataset);
const [timeFields, setTimeFields] = useState<DatasetField[]>();
const [timeFieldName, setTimeFieldName] = useState<string | undefined>();
const [timeFieldName, setTimeFieldName] = useState<string | undefined>(dataset.timeFieldName);
const [language, setLanguage] = useState<string>(() => {
const currentLanguage = queryString.getQuery().language;
if (languages.includes(currentLanguage)) {
Expand Down Expand Up @@ -94,7 +95,7 @@ export const Configurator = ({
}
)}
>
<EuiFieldText disabled value={baseDataset.title} />
<EuiFieldText disabled value={dataset.title} />
</EuiFormRow>
{timeFields && timeFields.length > 0 && (
<EuiFormRow
Expand All @@ -118,6 +119,7 @@ export const Configurator = ({
onChange={(e) => {
const value = e.target.value === 'undefined' ? undefined : e.target.value;
setTimeFieldName(value);
setDataset({ ...dataset, timeFieldName: value });
}}
/>
</EuiFormRow>
Expand All @@ -136,7 +138,10 @@ export const Configurator = ({
value: languageId,
}))}
value={language}
onChange={(e) => setLanguage(e.target.value)}
onChange={(e) => {
setLanguage(e.target.value);
setDataset({ ...dataset, language: e.target.value });
}}
/>
</EuiFormRow>
</EuiForm>
Expand All @@ -156,8 +161,8 @@ export const Configurator = ({
</EuiButton>
<EuiButton
onClick={() => {
queryString.getDatasetService().cacheDataset({ ...dataset, language, timeFieldName });
onConfirm({ ...dataset, language, timeFieldName });
queryString.getDatasetService().cacheDataset(dataset);
onConfirm(dataset);
}}
fill
>
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/query_enhancements/public/datasets/s3_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const fetchDatabases = async (http: HttpSetup, path: DataStructure[]): Promise<D
body: JSON.stringify({
lang: 'sql',
query: `SHOW DATABASES in ${connection.title}`,
datasource: dataSource?.title,
datasource: connection?.title,
...(meta.sessionId && { sessionId: meta.sessionId }),
}),
query: {
Expand All @@ -212,14 +212,14 @@ const fetchDatabases = async (http: HttpSetup, path: DataStructure[]): Promise<D

const fetchTables = async (http: HttpSetup, path: DataStructure[]): Promise<DataStructure[]> => {
const dataSource = path.find((ds) => ds.type === 'DATA_SOURCE');
const sessionId = (path.find((ds) => ds.type === 'CONNECTION')?.meta as DataStructureCustomMeta)
.sessionId;
const connection = path.find((ds) => ds.type === 'CONNECTION');
const sessionId = (connection?.meta as DataStructureCustomMeta).sessionId;
const database = path[path.length - 1];
const response = await http.post(`../../api/enhancements/datasource/jobs`, {
body: JSON.stringify({
lang: 'sql',
query: `SHOW TABLES in ${database.title}`,
datasource: dataSource?.title,
datasource: connection?.title,
...(sessionId && { sessionId }),
}),
query: {
Expand Down

0 comments on commit 999bc05

Please sign in to comment.