Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added fix for runAsync query without mds id #323

Merged
merged 18 commits into from
May 23, 2024
Merged
4 changes: 4 additions & 0 deletions public/components/Main/__snapshots__/main.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,8 @@ exports[`<Main /> spec click run button, and response is ok 1`] = `
>
<span
class="euiButton__text euiButtonGroupButton__textShift"
data-text="SQL"
title="SQL"
>
<input
checked=""
Expand All @@ -1431,6 +1433,8 @@ exports[`<Main /> spec click run button, and response is ok 1`] = `
>
<span
class="euiButton__text euiButtonGroupButton__textShift"
data-text="PPL"
title="PPL"
>
<input
class="euiScreenReaderOnly"
Expand Down
166 changes: 115 additions & 51 deletions server/routes/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
* SPDX-License-Identifier: Apache-2.0
*/


import { schema } from '@osd/config-schema';
import { IOpenSearchDashboardsResponse, IRouter, OpenSearchServiceSetup, ResponseError } from '../../../../src/core/server';
import {
IOpenSearchDashboardsResponse,
IRouter,
OpenSearchServiceSetup,
ResponseError,
} from '../../../../src/core/server';
import QueryService from '../services/QueryService';
import {
ROUTE_PATH_GET_DATASOURCES,
Expand All @@ -18,21 +22,29 @@
ROUTE_PATH_SQL_CSV,
ROUTE_PATH_SQL_JSON,
ROUTE_PATH_SQL_QUERY,
ROUTE_PATH_SQL_TEXT
ROUTE_PATH_SQL_TEXT,
} from '../utils/constants';

export default function query(server: IRouter, service: QueryService, openSearchServiceSetup: OpenSearchServiceSetup) {
export default function query(

Check failure on line 28 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

Prefer named exports
sumukhswamy marked this conversation as resolved.
Show resolved Hide resolved
server: IRouter,
service: QueryService,
openSearchServiceSetup: OpenSearchServiceSetup

Check failure on line 31 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

'openSearchServiceSetup' is defined but never used. Allowed unused args must match /^_/u
sumukhswamy marked this conversation as resolved.
Show resolved Hide resolved
) {
server.post(
{
path: ROUTE_PATH_SQL_QUERY,
validate: {
body: schema.any(),
query: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
})
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {

Check warning on line 47 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const retVal = await service.describeSQLQuery(context, request);
return response.ok({
body: retVal,
Expand All @@ -46,11 +58,15 @@
validate: {
body: schema.any(),
query: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
})
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {

Check warning on line 69 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const retVal = await service.describePPLQuery(context, request);
return response.ok({
body: retVal,
Expand All @@ -64,11 +80,15 @@
validate: {
body: schema.any(),
query: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
})
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {

Check warning on line 91 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const retVal = await service.describeSQLCsv(context, request);
return response.ok({
body: retVal,
Expand All @@ -82,11 +102,15 @@
validate: {
body: schema.any(),
query: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
})
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {

Check warning on line 113 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const retVal = await service.describePPLCsv(context, request);
return response.ok({
body: retVal,
Expand All @@ -100,11 +124,15 @@
validate: {
body: schema.any(),
query: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
})
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {

Check warning on line 135 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const retVal = await service.describeSQLJson(context, request);
return response.ok({
body: retVal,
Expand All @@ -118,11 +146,15 @@
validate: {
body: schema.any(),
query: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
})
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {

Check warning on line 157 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const retVal = await service.describePPLJson(context, request);
return response.ok({
body: retVal,
Expand All @@ -136,11 +168,15 @@
validate: {
body: schema.any(),
query: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
})
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {

Check warning on line 179 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const retVal = await service.describeSQLText(context, request);
return response.ok({
body: retVal,
Expand All @@ -154,11 +190,15 @@
validate: {
body: schema.any(),
query: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
})
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {

Check warning on line 201 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const retVal = await service.describePPLText(context, request);
return response.ok({
body: retVal,
Expand All @@ -172,73 +212,97 @@
validate: {
body: schema.any(),
query: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
})
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {

Check warning on line 223 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const retVal = await service.describeSQLAsyncQuery(context, request);
return response.ok({
body: retVal,
});
}
)
);

server.get(
{
path: ROUTE_PATH_SPARK_SQL_JOB_QUERY + "/{id}" + "/{dataSourceMDSId}",
path: ROUTE_PATH_SPARK_SQL_JOB_QUERY + '/{id}' + '/{dataSourceMDSId?}',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main change for this PR, rest are Linter changes

validate: {
params: schema.object({
id: schema.string(),
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
const retVal = await service.describeSQLAsyncGetQuery(context, request, request.params.id, request.params.dataSourceMDSId);
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {

Check warning on line 245 in server/routes/query.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const retVal = await service.describeSQLAsyncGetQuery(
context,
request,
request.params.id,
request.params.dataSourceMDSId
);
return response.ok({
body: retVal,
});
}
)
);

server.delete(
{
path: ROUTE_PATH_SPARK_SQL_JOB_QUERY + "/{id}" + "/{dataSourceMDSId?}",
path: ROUTE_PATH_SPARK_SQL_JOB_QUERY + '/{id}' + '/{dataSourceMDSId?}',
validate: {
params: schema.object({
id: schema.string(),
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
query: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
})
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
sumukhswamy marked this conversation as resolved.
Show resolved Hide resolved
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
const retVal = await service.describeAsyncDeleteQuery(context, request, request.params.id, request.params.dataSourceMDSId);
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
const retVal = await service.describeAsyncDeleteQuery(
context,
request,
request.params.id,
request.params.dataSourceMDSId
);
return response.ok({
body: retVal,
});
}
)
);

server.get(
{
path: `${ROUTE_PATH_GET_DATASOURCES}/{dataSourceMDSId?}`,
validate: {
params: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' }))
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
}),
},
},
async (context, request, response): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
async (
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
const retVal = await service.describeSyncQueryDataSources(context, request);
return response.ok({
body: retVal,
});
}
)


}
);
}
Loading