mirror of https://github.com/apache/druid.git
Web console: don't assume that activeTasks is an array (#17254)
This commit is contained in:
parent
2ffe7b177c
commit
babf7f2ef6
|
@ -20,7 +20,7 @@ import { ResizeSensor } from '@blueprintjs/core';
|
||||||
import type { QueryResult, SqlExpression, SqlQuery } from '@druid-toolkit/query';
|
import type { QueryResult, SqlExpression, SqlQuery } from '@druid-toolkit/query';
|
||||||
import React, { useMemo, useState } from 'react';
|
import React, { useMemo, useState } from 'react';
|
||||||
|
|
||||||
import type { ParameterDefinition, QuerySource } from '../../models';
|
import type { ParameterDefinition, ParameterValues, QuerySource } from '../../models';
|
||||||
import { effectiveParameterDefault, Stage } from '../../models';
|
import { effectiveParameterDefault, Stage } from '../../models';
|
||||||
import { ModuleRepository } from '../../module-repository/module-repository';
|
import { ModuleRepository } from '../../module-repository/module-repository';
|
||||||
import { Issue } from '../issue/issue';
|
import { Issue } from '../issue/issue';
|
||||||
|
@ -28,7 +28,7 @@ import { Issue } from '../issue/issue';
|
||||||
import './module-pane.scss';
|
import './module-pane.scss';
|
||||||
|
|
||||||
function fillInDefaults(
|
function fillInDefaults(
|
||||||
parameterValues: Record<string, any>,
|
parameterValues: ParameterValues,
|
||||||
parameters: Record<string, ParameterDefinition>,
|
parameters: Record<string, ParameterDefinition>,
|
||||||
querySource: QuerySource,
|
querySource: QuerySource,
|
||||||
): Record<string, any> {
|
): Record<string, any> {
|
||||||
|
@ -46,8 +46,8 @@ export interface ModulePaneProps {
|
||||||
where: SqlExpression;
|
where: SqlExpression;
|
||||||
setWhere(where: SqlExpression): void;
|
setWhere(where: SqlExpression): void;
|
||||||
|
|
||||||
parameterValues: Record<string, any>;
|
parameterValues: ParameterValues;
|
||||||
setParameterValues(parameters: Record<string, any>): void;
|
setParameterValues(parameters: ParameterValues): void;
|
||||||
runSqlQuery(query: string | SqlQuery): Promise<QueryResult>;
|
runSqlQuery(query: string | SqlQuery): Promise<QueryResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ interface ExploreStateValue {
|
||||||
showSourceQuery?: boolean;
|
showSourceQuery?: boolean;
|
||||||
where: SqlExpression;
|
where: SqlExpression;
|
||||||
moduleId: string;
|
moduleId: string;
|
||||||
parameterValues: Record<string, any>;
|
parameterValues: ParameterValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ExploreState {
|
export class ExploreState {
|
||||||
|
@ -64,7 +64,7 @@ export class ExploreState {
|
||||||
public readonly showSourceQuery: boolean;
|
public readonly showSourceQuery: boolean;
|
||||||
public readonly where: SqlExpression;
|
public readonly where: SqlExpression;
|
||||||
public readonly moduleId: string;
|
public readonly moduleId: string;
|
||||||
public readonly parameterValues: Record<string, any>;
|
public readonly parameterValues: ParameterValues;
|
||||||
|
|
||||||
public readonly parsedSource: SqlQuery | undefined;
|
public readonly parsedSource: SqlQuery | undefined;
|
||||||
public readonly parseError: string | undefined;
|
public readonly parseError: string | undefined;
|
||||||
|
@ -178,8 +178,10 @@ export class ExploreState {
|
||||||
parameterValues = {};
|
parameterValues = {};
|
||||||
} else {
|
} else {
|
||||||
moduleId = 'grouping-table';
|
moduleId = 'grouping-table';
|
||||||
parameterValues = this.moduleId === moduleId ? this.parameterValues : {};
|
parameterValues = {
|
||||||
parameterValues.splitColumns = [ExpressionMeta.fromColumn(column)];
|
...(this.moduleId === moduleId ? this.parameterValues : {}),
|
||||||
|
splitColumns: [ExpressionMeta.fromColumn(column)],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.change({
|
return this.change({
|
||||||
|
|
|
@ -186,7 +186,7 @@ export const ExploreView = React.memo(function ExploreView() {
|
||||||
}
|
}
|
||||||
}, [module, parameterValues, querySourceState.data]);
|
}, [module, parameterValues, querySourceState.data]);
|
||||||
|
|
||||||
function setModuleId(moduleId: string, parameterValues: Record<string, any>) {
|
function setModuleId(moduleId: string, parameterValues: ParameterValues) {
|
||||||
if (exploreState.moduleId === moduleId) return;
|
if (exploreState.moduleId === moduleId) return;
|
||||||
setExploreState(exploreState.change({ moduleId, parameterValues }));
|
setExploreState(exploreState.change({ moduleId, parameterValues }));
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ export const ExploreView = React.memo(function ExploreView() {
|
||||||
<ModulePicker
|
<ModulePicker
|
||||||
selectedModuleId={moduleId}
|
selectedModuleId={moduleId}
|
||||||
onSelectedModuleIdChange={newModuleId => {
|
onSelectedModuleIdChange={newModuleId => {
|
||||||
const newParameterValues = getStickyParameterValuesForModule(newModuleId);
|
let newParameterValues = getStickyParameterValuesForModule(newModuleId);
|
||||||
|
|
||||||
const oldModule = ModuleRepository.getModule(moduleId);
|
const oldModule = ModuleRepository.getModule(moduleId);
|
||||||
const newModule = ModuleRepository.getModule(newModuleId);
|
const newModule = ModuleRepository.getModule(newModuleId);
|
||||||
|
@ -349,11 +349,14 @@ export const ExploreView = React.memo(function ExploreView() {
|
||||||
);
|
);
|
||||||
if (!target) continue;
|
if (!target) continue;
|
||||||
|
|
||||||
newParameterValues[target[0]] = adjustTransferValue(
|
newParameterValues = {
|
||||||
parameterValue,
|
...newParameterValues,
|
||||||
oldParameterDefinition.type,
|
[target[0]]: adjustTransferValue(
|
||||||
target[1].type,
|
parameterValue,
|
||||||
);
|
oldParameterDefinition.type,
|
||||||
|
target[1].type,
|
||||||
|
),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ import type { QuerySource } from './query-source';
|
||||||
|
|
||||||
export type OptionValue = string | number;
|
export type OptionValue = string | number;
|
||||||
|
|
||||||
export type ModuleFunctor<T> = T | ((options: { parameterValues: Record<string, any> }) => T);
|
export type ModuleFunctor<T> = T | ((options: { parameterValues: ParameterValues }) => T);
|
||||||
|
|
||||||
export function evaluateFunctor<T>(fn: ModuleFunctor<T>, parameterValues: Record<string, any>): T {
|
export function evaluateFunctor<T>(fn: ModuleFunctor<T>, parameterValues: ParameterValues): T {
|
||||||
if (typeof fn === 'function') {
|
if (typeof fn === 'function') {
|
||||||
return (fn as any)({ parameterValues });
|
return (fn as any)({ parameterValues });
|
||||||
} else {
|
} else {
|
||||||
|
@ -144,7 +144,7 @@ export function getModuleOptionLabel(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ParameterValues = Record<string, any>;
|
export type ParameterValues = Readonly<Record<string, any>>;
|
||||||
export type Parameters = Record<string, ParameterDefinition>;
|
export type Parameters = Record<string, ParameterDefinition>;
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
|
@ -843,10 +843,14 @@ export class SupervisorsView extends React.PureComponent<
|
||||||
accessor: 'stats',
|
accessor: 'stats',
|
||||||
Cell: ({ value, original }) => {
|
Cell: ({ value, original }) => {
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
const activeTaskIds: string[] | undefined = deepGet(
|
const activeTasks: SupervisorStatusTask[] | undefined = deepGet(
|
||||||
original,
|
original,
|
||||||
'status.payload.activeTasks',
|
'status.payload.activeTasks',
|
||||||
)?.map((t: SupervisorStatusTask) => t.id);
|
);
|
||||||
|
const activeTaskIds: string[] | undefined = Array.isArray(activeTasks)
|
||||||
|
? activeTasks.map((t: SupervisorStatusTask) => t.id)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const c = getTotalSupervisorStats(value, statsKey, activeTaskIds);
|
const c = getTotalSupervisorStats(value, statsKey, activeTaskIds);
|
||||||
const seconds = getRowStatsKeySeconds(statsKey);
|
const seconds = getRowStatsKeySeconds(statsKey);
|
||||||
const totalLabel = `Total (past ${statsKey}): `;
|
const totalLabel = `Total (past ${statsKey}): `;
|
||||||
|
|
Loading…
Reference in New Issue