Skip to content

Commit e3250f6

Browse files
committed
Retain identifying properties for all JSON plans
Keep each configured node type key in the public properties map while continuing to use it for node names and rendering. This lets generic insights classify JSON plan nodes without loader-specific opt-ins. Remove the retainNodeTypeProperty configuration switch, cover identifying properties across JSON loaders, and update loader result snapshots.
1 parent 669c485 commit e3250f6

5 files changed

Lines changed: 304 additions & 307 deletions

File tree

‎query-graphs/src/loaders/decorated-json-tree.ts‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ export function createDecoratedJsonTreeState(): DecoratedJsonTreeState {
3838
export interface DecoratedJsonTreeConfig {
3939
/** Object keys whose scalar values identify a semantic node type, in precedence order. */
4040
nodeTypeKeys: readonly string[];
41-
/** Keep the selected node-type field in the tooltip instead of using it only as the node name. */
42-
retainNodeTypeProperty?: boolean;
4341
/** Show these structural children in the listed order and omit their redundant key wrapper. */
4442
structuralChildKeys: readonly string[];
4543
/** Keep these values in the tooltip even when they are objects or arrays. */
@@ -64,13 +62,12 @@ export interface DecoratedJsonTreeConfig {
6462
getActualCardinality?(rawNode: JsonObject): number | undefined;
6563
}
6664

67-
function orderedKeys(rawNode: JsonObject, nodeTypeKey: string | undefined, config: DecoratedJsonTreeConfig): string[] {
65+
function orderedKeys(rawNode: JsonObject, config: DecoratedJsonTreeConfig): string[] {
6866
// Enforce a format-specific order for structural children (for example,
6967
// "left" before "right") and display all remaining keys alphabetically.
7068
return Object.getOwnPropertyNames(rawNode)
7169
.filter(
7270
(key) =>
73-
(key !== nodeTypeKey || config.retainNodeTypeProperty) &&
7471
!config.alwaysPropertyKeys.includes(key) &&
7572
!(config.flattenPropertyObjectKeys?.includes(key) && isJsonObject(rawNode[key])),
7673
)
@@ -155,8 +152,9 @@ function convertDecoratedJsonValue(
155152
const expandedChildren: TreeNode[] = [];
156153
const collapsedChildren: TreeNode[] = [];
157154
const properties = new Map<string, string>();
158-
// Classify semantic nodes before processing their remaining fields so the
159-
// identifying key itself does not also appear as a tooltip property.
155+
// Classify semantic nodes before processing their fields so the identifying
156+
// property can also drive format-specific rendering and source links. It remains
157+
// in the properties map so generic insights can inspect it.
160158
const {nodeTypeKey, nodeTag} = classifyNode(rawNode, config);
161159

162160
// Some complex values are more useful as tooltip properties than subtrees.
@@ -179,7 +177,7 @@ function convertDecoratedJsonValue(
179177

180178
// Display remaining fields adaptively: scalars become tooltip properties,
181179
// while objects and arrays remain visible in the tree.
182-
for (const key of orderedKeys(rawNode, nodeTypeKey, config)) {
180+
for (const key of orderedKeys(rawNode, config)) {
183181
const value = tryToString(rawNode[key]);
184182
if (value !== undefined) {
185183
properties.set(key, value);

‎query-graphs/src/loaders/hyper.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ function containsOperator(value: Json): boolean {
126126

127127
const hyperConfig: DecoratedJsonTreeConfig = {
128128
nodeTypeKeys: ["operator", "expression"],
129-
retainNodeTypeProperty: true,
130129
structuralChildKeys: ["inputs", "input", "left", "right", "value", "value-for-comparison"],
131130
alwaysPropertyKeys: ["debug-name", "statistics", "sqlpos"],
132131
getRenderingConfig(nodeType, nodeTag, rawNode) {

‎query-graphs/src/loaders/json.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {JsonPlanLoader} from "./types";
1313

1414
const jsonTreeConfig: DecoratedJsonTreeConfig = {
1515
nodeTypeKeys: ["name"],
16-
retainNodeTypeProperty: true,
1716
structuralChildKeys: [],
1817
alwaysPropertyKeys: [],
1918
getRenderingConfig: () => ({}),

0 commit comments

Comments
 (0)