Skip to content

Commit

Permalink
Make Aggregate nodes more consistent in TEXT and JSON
Browse files Browse the repository at this point in the history
JSON has a "Strategy" key to distinguish aggregate types. Here we
convert this to what the TEXT format uses.

Fixes #495
  • Loading branch information
pgiraud committed Aug 22, 2024
1 parent e2ae0d1 commit b407175
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export enum NodeProp {
PRE_SORTED_GROUPS = "Pre-sorted Groups",
PRESORTED_KEY = "Presorted Key",
FILTER = "Filter",
STRATEGY = "Strategy",

// computed by pev
NODE_ID = "nodeId",
Expand Down
1 change: 1 addition & 0 deletions src/services/help-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ const notMiscProperties: string[] = [
NodeProp.RELATION_NAME,
NodeProp.ALIAS,
NodeProp.FUNCTION_NAME,
NodeProp.STRATEGY,
]

export function shouldShowProp(key: string, value: unknown): boolean {
Expand Down
22 changes: 22 additions & 0 deletions src/services/plan-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export class PlanService {
this.calculateActuals(node)
this.calculateExclusives(node)
this.calculateIoTimingsAverage(node)
this.convertNodeType(node)
}

public calculateMaximums(plan: IPlan) {
Expand Down Expand Up @@ -1241,4 +1242,25 @@ export class PlanService {
return _.has(child, NodeProp.OUTPUT) || this.findOutputProperty(child)
})
}

private convertNodeType(node: Node): void {
// Convert some node type (possibly from JSON source) to match the TEXT format
if (node[NodeProp.NODE_TYPE] == "Aggregate") {
let prefix = ""
switch (node[NodeProp.STRATEGY]) {
case "Sorted":
prefix = "Group"
break
case "Hashed":
prefix = "Hash"
break
case "Plain":
prefix = ""
break
default:
console.error("Unsupported Aggregate Strategy")
}
node[NodeProp.NODE_TYPE] = prefix + "Aggregate"
}
}
}

0 comments on commit b407175

Please sign in to comment.