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

Web console: add support for Dart engine #17147

Merged
merged 9 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ exports[`HeaderBar matches snapshot 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": true,
"multiStageQueryTask": true,
"overlord": true,
"queryType": "nativeAndSql",
Expand Down
9 changes: 7 additions & 2 deletions web-console/src/druid-models/druid-engine/druid-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@
* limitations under the License.
*/

export type DruidEngine = 'native' | 'sql-native' | 'sql-msq-task';
export type DruidEngine = 'native' | 'sql-native' | 'sql-msq-task' | 'sql-msq-dart';

export const DRUID_ENGINES: DruidEngine[] = ['native', 'sql-native', 'sql-msq-task'];
export const DRUID_ENGINES: DruidEngine[] = [
'native',
'sql-native',
'sql-msq-task',
'sql-msq-dart',
];

export function validDruidEngine(
possibleDruidEngine: string | undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ export class WorkbenchQuery {
};

let cancelQueryId: string | undefined;
if (engine === 'sql-native') {
if (engine === 'sql-native' || engine === 'sql-msq-dart') {
cancelQueryId = apiQuery.context.sqlQueryId;
if (!cancelQueryId) {
// If the sqlQueryId is not explicitly set on the context generate one, so it is possible to cancel the query.
Expand All @@ -550,6 +550,10 @@ export class WorkbenchQuery {
apiQuery.context.sqlStringifyArrays ??= false;
}

if (engine === 'sql-msq-dart') {
apiQuery.context.fullReport ??= true;
}

if (Array.isArray(queryParameters) && queryParameters.length) {
apiQuery.parameters = queryParameters;
}
Expand Down
32 changes: 31 additions & 1 deletion web-console/src/helpers/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type QueryType = 'none' | 'nativeOnly' | 'nativeAndSql';
export interface CapabilitiesValue {
queryType: QueryType;
multiStageQueryTask: boolean;
multiStageQueryDart: boolean;
coordinator: boolean;
overlord: boolean;
maxTaskSlots?: number;
Expand All @@ -53,6 +54,7 @@ export class Capabilities {

private readonly queryType: QueryType;
private readonly multiStageQueryTask: boolean;
private readonly multiStageQueryDart: boolean;
private readonly coordinator: boolean;
private readonly overlord: boolean;
private readonly maxTaskSlots?: number;
Expand Down Expand Up @@ -139,6 +141,15 @@ export class Capabilities {
}
}

static async detectMultiStageQueryDart(): Promise<boolean> {
try {
const resp = await Api.instance.get(`/druid/v2/sql/dart/enabled?capabilities`);
return Boolean(resp.data.enabled);
} catch {
return false;
}
}

static async detectCapabilities(): Promise<Capabilities | undefined> {
const queryType = await Capabilities.detectQueryType();
if (typeof queryType === 'undefined') return;
Expand All @@ -154,11 +165,15 @@ export class Capabilities {
coordinator = overlord = await Capabilities.detectManagementProxy();
}

const multiStageQueryTask = await Capabilities.detectMultiStageQueryTask();
const [multiStageQueryTask, multiStageQueryDart] = await Promise.all([
Capabilities.detectMultiStageQueryTask(),
Capabilities.detectMultiStageQueryDart(),
]);

return new Capabilities({
queryType,
multiStageQueryTask,
multiStageQueryDart,
coordinator,
overlord,
});
Expand All @@ -179,6 +194,7 @@ export class Capabilities {
constructor(value: CapabilitiesValue) {
this.queryType = value.queryType;
this.multiStageQueryTask = value.multiStageQueryTask;
this.multiStageQueryDart = value.multiStageQueryDart;
this.coordinator = value.coordinator;
this.overlord = value.overlord;
this.maxTaskSlots = value.maxTaskSlots;
Expand All @@ -188,6 +204,7 @@ export class Capabilities {
return {
queryType: this.queryType,
multiStageQueryTask: this.multiStageQueryTask,
multiStageQueryDart: this.multiStageQueryDart,
coordinator: this.coordinator,
overlord: this.overlord,
maxTaskSlots: this.maxTaskSlots,
Expand Down Expand Up @@ -248,6 +265,10 @@ export class Capabilities {
return this.multiStageQueryTask;
}

public hasMultiStageQueryDart(): boolean {
return this.multiStageQueryDart;
}

public getSupportedQueryEngines(): DruidEngine[] {
const queryEngines: DruidEngine[] = ['native'];
if (this.hasSql()) {
Expand All @@ -256,6 +277,9 @@ export class Capabilities {
if (this.hasMultiStageQueryTask()) {
queryEngines.push('sql-msq-task');
}
if (this.hasMultiStageQueryDart()) {
queryEngines.push('sql-msq-dart');
}
return queryEngines;
}

Expand All @@ -282,36 +306,42 @@ export class Capabilities {
Capabilities.FULL = new Capabilities({
queryType: 'nativeAndSql',
multiStageQueryTask: true,
multiStageQueryDart: true,
coordinator: true,
overlord: true,
});
Capabilities.NO_SQL = new Capabilities({
queryType: 'nativeOnly',
multiStageQueryTask: false,
multiStageQueryDart: false,
coordinator: true,
overlord: true,
});
Capabilities.COORDINATOR_OVERLORD = new Capabilities({
queryType: 'none',
multiStageQueryTask: false,
multiStageQueryDart: false,
coordinator: true,
overlord: true,
});
Capabilities.COORDINATOR = new Capabilities({
queryType: 'none',
multiStageQueryTask: false,
multiStageQueryDart: false,
coordinator: true,
overlord: false,
});
Capabilities.OVERLORD = new Capabilities({
queryType: 'none',
multiStageQueryTask: false,
multiStageQueryDart: false,
coordinator: false,
overlord: true,
});
Capabilities.NO_PROXY = new Capabilities({
queryType: 'nativeAndSql',
multiStageQueryTask: true,
multiStageQueryDart: false,
coordinator: false,
overlord: false,
});
13 changes: 13 additions & 0 deletions web-console/src/utils/druid-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,19 @@ export async function queryDruidSql<T = any>(
return sqlResultResp.data;
}

export async function queryDruidSqlDart<T = any>(
sqlQueryPayload: Record<string, any>,
cancelToken?: CancelToken,
): Promise<T[]> {
let sqlResultResp: AxiosResponse;
try {
sqlResultResp = await Api.instance.post('/druid/v2/sql/dart', sqlQueryPayload, { cancelToken });
} catch (e) {
throw new Error(getDruidErrorMessage(e));
}
return sqlResultResp.data;
}

export interface QueryExplanation {
query: any;
signature: { name: string; type: string }[];
Expand Down
1 change: 1 addition & 0 deletions web-console/src/utils/local-storage-keys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const LocalStorageKeys = {
WORKBENCH_PANE_SIZE: 'workbench-pane-size' as const,
WORKBENCH_HISTORY: 'workbench-history' as const,
WORKBENCH_TASK_PANEL: 'workbench-task-panel' as const,
WORKBENCH_DART_PANEL: 'workbench-dart-panel' as const,

SQL_DATA_LOADER_CONTENT: 'sql-data-loader-content' as const,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`HomeView matches snapshot (coordinator) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": false,
"multiStageQueryTask": false,
"overlord": false,
"queryType": "none",
Expand All @@ -21,6 +22,7 @@ exports[`HomeView matches snapshot (coordinator) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": false,
"multiStageQueryTask": false,
"overlord": false,
"queryType": "none",
Expand All @@ -32,6 +34,7 @@ exports[`HomeView matches snapshot (coordinator) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": false,
"multiStageQueryTask": false,
"overlord": false,
"queryType": "none",
Expand All @@ -44,6 +47,7 @@ exports[`HomeView matches snapshot (coordinator) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": false,
"multiStageQueryTask": false,
"overlord": false,
"queryType": "none",
Expand All @@ -55,6 +59,7 @@ exports[`HomeView matches snapshot (coordinator) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": false,
"multiStageQueryTask": false,
"overlord": false,
"queryType": "none",
Expand All @@ -73,6 +78,7 @@ exports[`HomeView matches snapshot (full) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": true,
"multiStageQueryTask": true,
"overlord": true,
"queryType": "nativeAndSql",
Expand All @@ -85,6 +91,7 @@ exports[`HomeView matches snapshot (full) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": true,
"multiStageQueryTask": true,
"overlord": true,
"queryType": "nativeAndSql",
Expand All @@ -96,6 +103,7 @@ exports[`HomeView matches snapshot (full) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": true,
"multiStageQueryTask": true,
"overlord": true,
"queryType": "nativeAndSql",
Expand All @@ -109,6 +117,7 @@ exports[`HomeView matches snapshot (full) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": true,
"multiStageQueryTask": true,
"overlord": true,
"queryType": "nativeAndSql",
Expand All @@ -120,6 +129,7 @@ exports[`HomeView matches snapshot (full) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": true,
"multiStageQueryTask": true,
"overlord": true,
"queryType": "nativeAndSql",
Expand All @@ -132,6 +142,7 @@ exports[`HomeView matches snapshot (full) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": true,
"multiStageQueryTask": true,
"overlord": true,
"queryType": "nativeAndSql",
Expand All @@ -143,6 +154,7 @@ exports[`HomeView matches snapshot (full) 1`] = `
Capabilities {
"coordinator": true,
"maxTaskSlots": undefined,
"multiStageQueryDart": true,
"multiStageQueryTask": true,
"overlord": true,
"queryType": "nativeAndSql",
Expand All @@ -161,6 +173,7 @@ exports[`HomeView matches snapshot (overlord) 1`] = `
Capabilities {
"coordinator": false,
"maxTaskSlots": undefined,
"multiStageQueryDart": false,
"multiStageQueryTask": false,
"overlord": true,
"queryType": "none",
Expand All @@ -173,6 +186,7 @@ exports[`HomeView matches snapshot (overlord) 1`] = `
Capabilities {
"coordinator": false,
"maxTaskSlots": undefined,
"multiStageQueryDart": false,
"multiStageQueryTask": false,
"overlord": true,
"queryType": "none",
Expand All @@ -184,6 +198,7 @@ exports[`HomeView matches snapshot (overlord) 1`] = `
Capabilities {
"coordinator": false,
"maxTaskSlots": undefined,
"multiStageQueryDart": false,
"multiStageQueryTask": false,
"overlord": true,
"queryType": "none",
Expand Down
Loading
Loading