Skip to content

Commit

Permalink
[UI] show missing operators in stage tab
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonidChistov authored and tdcmeehan committed Dec 3, 2024
1 parent ca26526 commit 55479fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 100 deletions.
54 changes: 5 additions & 49 deletions presto-ui/src/components/QueryStageView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,45 +334,14 @@ function StageOperatorGraph({ id, stage }) {

const detailContainer = React.useRef(null);

const computeOperatorMap = () => {
const operatorMap = new Map();
stage.latestAttemptExecutionInfo.stats.operatorSummaries.forEach(operator => {
if (!operatorMap.has(operator.planNodeId)) {
operatorMap.set(operator.planNodeId, [])
}

operatorMap.get(operator.planNodeId).push(operator);
});

return operatorMap;
};

const computeOperatorGraphs = (planNode, operatorMap) => {
const sources = getChildren(planNode);
const sourceResults = new Map();
sources.forEach(source => {
const sourceResult = computeOperatorGraphs(source, operatorMap);
sourceResult.forEach((operator, pipelineId) => {
if (sourceResults.has(pipelineId)) {
console.error("Multiple sources for ", planNode['@type'], " had the same pipeline ID");
return sourceResults;
}
sourceResults.set(pipelineId, operator);
});
});

let nodeOperators = operatorMap.get(planNode.id);
if (!nodeOperators || nodeOperators.length === 0) {
return sourceResults;
}

const computeOperatorGraphs = () => {
const pipelineOperators = new Map();
nodeOperators.forEach(operator => {
stage.latestAttemptExecutionInfo.stats.operatorSummaries.forEach(operator => {
if (!pipelineOperators.has(operator.pipelineId)) {
pipelineOperators.set(operator.pipelineId, []);
}
pipelineOperators.get(operator.pipelineId).push(operator);
});
});

const result = new Map();
pipelineOperators.forEach((pipelineOperators, pipelineId) => {
Expand All @@ -381,13 +350,6 @@ function StageOperatorGraph({ id, stage }) {
const sinkOperator = linkedOperators[linkedOperators.length - 1];
const sourceOperator = linkedOperators[0];

if (sourceResults.has(pipelineId)) {
const pipelineChildResult = sourceResults.get(pipelineId);
if (pipelineChildResult) {
sourceOperator.child = pipelineChildResult;
}
}

// chain operators at this level
let currentOperator = sourceOperator;
linkedOperators.slice(1).forEach(source => {
Expand All @@ -398,21 +360,15 @@ function StageOperatorGraph({ id, stage }) {
result.set(pipelineId, sinkOperator);
});

sourceResults.forEach((operator, pipelineId) => {
if (!result.has(pipelineId)) {
result.set(pipelineId, operator);
}
});

return result;
};

React.useEffect(() => {
if (!stage) {
return;
}
const operatorMap = computeOperatorMap();
const operatorGraphs = computeOperatorGraphs(stage.plan.root, operatorMap);

const operatorGraphs = computeOperatorGraphs();

const graph = initializeGraph();
operatorGraphs.forEach((operator, pipelineId) => {
Expand Down
55 changes: 4 additions & 51 deletions presto-ui/src/components/StageDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,33 +372,14 @@ class StageOperatorGraph extends React.Component {
document.getElementById('operator-detail'));
}

computeOperatorGraphs(planNode, operatorMap) {
const sources = getChildren(planNode);

const sourceResults = new Map();
sources.forEach(source => {
const sourceResult = this.computeOperatorGraphs(source, operatorMap);
sourceResult.forEach((operator, pipelineId) => {
if (sourceResults.has(pipelineId)) {
console.error("Multiple sources for ", planNode['@type'], " had the same pipeline ID");
return sourceResults;
}
sourceResults.set(pipelineId, operator);
});
});

let nodeOperators = operatorMap.get(planNode.id);
if (!nodeOperators || nodeOperators.length === 0) {
return sourceResults;
}

computeOperatorGraphs() {
const pipelineOperators = new Map();
nodeOperators.forEach(operator => {
this.props.stage.latestAttemptExecutionInfo.stats.operatorSummaries.forEach(operator => {
if (!pipelineOperators.has(operator.pipelineId)) {
pipelineOperators.set(operator.pipelineId, []);
}
pipelineOperators.get(operator.pipelineId).push(operator);
});
});

const result = new Map();
pipelineOperators.forEach((pipelineOperators, pipelineId) => {
Expand All @@ -407,13 +388,6 @@ class StageOperatorGraph extends React.Component {
const sinkOperator = linkedOperators[linkedOperators.length - 1];
const sourceOperator = linkedOperators[0];

if (sourceResults.has(pipelineId)) {
const pipelineChildResult = sourceResults.get(pipelineId);
if (pipelineChildResult) {
sourceOperator.child = pipelineChildResult;
}
}

// chain operators at this level
let currentOperator = sourceOperator;
linkedOperators.slice(1).forEach(source => {
Expand All @@ -424,28 +398,9 @@ class StageOperatorGraph extends React.Component {
result.set(pipelineId, sinkOperator);
});

sourceResults.forEach((operator, pipelineId) => {
if (!result.has(pipelineId)) {
result.set(pipelineId, operator);
}
});

return result;
}

computeOperatorMap() {
const operatorMap = new Map();
this.props.stage.latestAttemptExecutionInfo.stats.operatorSummaries.forEach(operator => {
if (!operatorMap.has(operator.planNodeId)) {
operatorMap.set(operator.planNodeId, [])
}

operatorMap.get(operator.planNodeId).push(operator);
});

return operatorMap;
}

computeD3StageOperatorGraph(graph, operator, sink, pipelineNode) {
const operatorNodeId = "operator-" + operator.pipelineId + "-" + operator.operatorId;

Expand All @@ -469,9 +424,7 @@ class StageOperatorGraph extends React.Component {
return;
}

const stage = this.props.stage;
const operatorMap = this.computeOperatorMap();
const operatorGraphs = this.computeOperatorGraphs(stage.plan.root, operatorMap);
const operatorGraphs = this.computeOperatorGraphs();

const graph = initializeGraph();
operatorGraphs.forEach((operator, pipelineId) => {
Expand Down

0 comments on commit 55479fb

Please sign in to comment.