Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions src/testing/jobs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import assert from "assert";
import { TestSuite } from ".";
import { getInstance } from "../base";
import { ExplainTree } from "../views/results/explain/nodes";
import { ServerComponent } from "../connection/serverComponent";
import { OldSQLJob } from "../connection/sqlJob";
import { VisualExplainData } from "../types";
import { ExplainTree } from "../views/results/explain/nodes";

export const JobsSuite: TestSuite = {
name: `Connection tests`,
Expand Down Expand Up @@ -385,7 +386,7 @@ export const JobsSuite: TestSuite = {

const query = `select * from qiws.qcustcdt`;

const result = await newJob.explain(query);
const result = await newJob.explain<VisualExplainData>(query);

const tree = new ExplainTree(result.data);

Expand Down
157 changes: 90 additions & 67 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,91 @@
// https://www.ibm.com/docs/en/i/7.4?topic=views-syscolumns2
export interface TableColumn {
TABLE_SCHEMA: string,
TABLE_NAME: string,
COLUMN_NAME: string,
SYSTEM_COLUMN_NAME: string,
CONSTRAINT_NAME?: string,
DATA_TYPE: string,
CHARACTER_MAXIMUM_LENGTH?: number,
NUMERIC_SCALE?: number,
NUMERIC_PRECISION?: number,
IS_NULLABLE: "Y" | "N",
HAS_DEFAULT: "Y" | "N",
COLUMN_DEFAULT?: string,
COLUMN_TEXT: string,
IS_IDENTITY: "YES" | "NO",
}

// https://www.ibm.com/docs/en/i/7.4?topic=views-sysparms
export interface SQLParm {
SPECIFIC_SCHEMA: string,
SPECIFIC_NAME: string,
PARAMETER_NAME: string,
PARAMETER_MODE: "IN" | "OUT" | "INOUT",
DATA_TYPE: string,
CHARACTER_MAXIMUM_LENGTH?: number,
NUMERIC_SCALE?: number,
NUMERIC_PRECISION?: number,
IS_NULLABLE: "YES" | "NO",
DEFAULT?: string,
LONG_COMMENT?: string,
ORDINAL_POSITION: number,
ROW_TYPE: "P" | "R",
}

export interface ResolvedSqlObject {
schema: string;
name: string;
sqlType: string;
}

export interface BasicSQLObject {
type: string;
tableType: string;
constraintType: string;
schema: string;
name: string;
specificName: string;
text: string;
system: {
schema: string;
name: string;
}
basedOn: {
schema: string;
name: string;
}
}

export interface CPYFOptions {
toLib: string;
toFile: string;
fromMbr: string;
toMbr: string;
mbrOpt: string;
crtFile: string;
outFmt: string
// https://www.ibm.com/docs/en/i/7.4?topic=views-syscolumns2
export interface TableColumn {
TABLE_SCHEMA: string,
TABLE_NAME: string,
COLUMN_NAME: string,
SYSTEM_COLUMN_NAME: string,
CONSTRAINT_NAME?: string,
DATA_TYPE: string,
CHARACTER_MAXIMUM_LENGTH?: number,
NUMERIC_SCALE?: number,
NUMERIC_PRECISION?: number,
IS_NULLABLE: "Y" | "N",
HAS_DEFAULT: "Y" | "N",
COLUMN_DEFAULT?: string,
COLUMN_TEXT: string,
IS_IDENTITY: "YES" | "NO",
}

// https://www.ibm.com/docs/en/i/7.4?topic=views-sysparms
export interface SQLParm {
SPECIFIC_SCHEMA: string,
SPECIFIC_NAME: string,
PARAMETER_NAME: string,
PARAMETER_MODE: "IN" | "OUT" | "INOUT",
DATA_TYPE: string,
CHARACTER_MAXIMUM_LENGTH?: number,
NUMERIC_SCALE?: number,
NUMERIC_PRECISION?: number,
IS_NULLABLE: "YES" | "NO",
DEFAULT?: string,
LONG_COMMENT?: string,
ORDINAL_POSITION: number,
ROW_TYPE: "P" | "R",
}

export interface ResolvedSqlObject {
schema: string;
name: string;
sqlType: string;
}

export interface BasicSQLObject {
type: string;
tableType: string;
constraintType: string;
schema: string;
name: string;
specificName: string;
text: string;
system: {
schema: string;
name: string;
}
basedOn: {
schema: string;
name: string;
}
}

export interface CPYFOptions {
toLib: string;
toFile: string;
fromMbr: string;
toMbr: string;
mbrOpt: string;
crtFile: string;
outFmt: string
}

export interface VisualExplainData {
IFA_ARWVAL: number
IFA_CHROUT: string
IFA_COLHDG: string
IFA_COLTYP: number
IFA_CTXORD: number
IFA_CTXTYP: number
IFA_DBLBYT: string
IFA_DEBUG: number
IFA_DESCR: number
IFA_FLYORD: number
IFA_FMTVAL: number
IFA_FUT2: number
IFA_FUT3: number
IFA_FUT8: number
IFA_FUT9: number
IFA_HEXOUT: string
IFA_ICON: number
IFA_IFLAG: string
IFA_NUMOUT: number
IFA_TYPOUT: string
}
84 changes: 42 additions & 42 deletions src/views/results/explain/doveResultsView.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from "vscode";
import { CancellationToken, Event, EventEmitter, ProviderResult, TreeView, TreeDataProvider, TreeItem, TreeItemCollapsibleState, commands, ThemeIcon } from "vscode";
import { ExplainNode } from "./nodes";
import { CancellationToken, commands, Event, EventEmitter, ProviderResult, ThemeIcon, TreeDataProvider, TreeItem, TreeItemCollapsibleState, TreeView } from "vscode";
import { toDoveTreeDecorationProviderUri } from "./doveTreeDecorationProvider";
import { ExplainNode } from "./nodes";

/**
* Icon labels as defined by the API, along with the name of the icon to display.
Expand All @@ -11,44 +11,44 @@ import { toDoveTreeDecorationProviderUri } from "./doveTreeDecorationProvider";
* @see https://code.visualstudio.com/api/references/icons-in-labels
*/
const icons = {
"Bitmap Merge": `merge`,
"Cache": ``,
"Cache Probe": ``,
"Delete": `trash`,
"Distinct": `list-flat`,
"Dynamic Bitmap": `symbol-misc`,
"Encoded Vector Index": `symbol-reference`,
"Encoded Vector Index, Parallel": `symbol-reference`,
"Final Select": `selection`,
"Hash Grouping": `group-by-ref-type`,
"Hash Join": `add`,
"Hash Scan": `search`,
"Index Grouping": `group-by-ref-type`,
"Index Scan - Key Positioning": `key`,
"Bitmap Merge": `merge`,
"Cache": ``,
"Cache Probe": ``,
"Delete": `trash`,
"Distinct": `list-flat`,
"Dynamic Bitmap": `symbol-misc`,
"Encoded Vector Index": `symbol-reference`,
"Encoded Vector Index, Parallel": `symbol-reference`,
"Final Select": `selection`,
"Hash Grouping": `group-by-ref-type`,
"Hash Join": `add`,
"Hash Scan": `search`,
"Index Grouping": `group-by-ref-type`,
"Index Scan - Key Positioning": `key`,
"Index Scan - Key Positioning, Parallel": `key`,
"Index Scan - Key Selection": `key`,
"Index Scan - Key Selection, Parallel": `key`,
"Insert": `insert`,
"Nested Loop Join": `add`,
"Select": `selection`,
"Skip Sequential Table Scan": `list-unordered`,
"Skip Sequential Table Scan, Parallel": `list-unordered`,
"Sort": `sort-precedence`,
"Sorted List Scan": `list-ordered`,
"Subquery Merge": `merge`,
"Table Probe": `list-selection`,
"Table Scan": `search`,
"Table Scan, Parallel": `search`,
"Temporary Distinct Hash Table": `new-file`,
"Temporary Hash Table": `new-file`,
"Temporary Index": `new-file`,
"Temporary Sorted List": `list-ordered`,
"Temporary Table": `new-file`,
"Union Merge": `merge`,
"User Defined Table Function": `symbol-function`,
"Unknown": `question`,
"Update": `replace`,
"VALUES LIST": `list-flat`,
"Index Scan - Key Selection": `key`,
"Index Scan - Key Selection, Parallel": `key`,
"Insert": `insert`,
"Nested Loop Join": `add`,
"Select": `selection`,
"Skip Sequential Table Scan": `list-unordered`,
"Skip Sequential Table Scan, Parallel": `list-unordered`,
"Sort": `sort-precedence`,
"Sorted List Scan": `list-ordered`,
"Subquery Merge": `merge`,
"Table Probe": `list-selection`,
"Table Scan": `search`,
"Table Scan, Parallel": `search`,
"Temporary Distinct Hash Table": `new-file`,
"Temporary Hash Table": `new-file`,
"Temporary Index": `new-file`,
"Temporary Sorted List": `list-ordered`,
"Temporary Table": `new-file`,
"Union Merge": `merge`,
"User Defined Table Function": `symbol-function`,
"Unknown": `question`,
"Update": `replace`,
"VALUES LIST": `list-flat`,
}

type ChangeTreeDataEventType = ExplainTreeItem | undefined | null | void;
Expand All @@ -60,7 +60,7 @@ export class DoveResultsView implements TreeDataProvider<any> {
private topNode: ExplainTreeItem;

private treeView: TreeView<ExplainTreeItem>;

constructor() {
this.treeView = vscode.window.createTreeView(`vscode-db2i.dove.nodes`, { treeDataProvider: this, showCollapseAll: true });
}
Expand All @@ -76,7 +76,7 @@ export class DoveResultsView implements TreeDataProvider<any> {
// Show tree in the view
commands.executeCommand(`setContext`, `vscode-db2i:explaining`, true);
// Ensure that the tree is positioned such that the first element is visible
this.treeView.reveal(this.topNode, { select: false });
this.treeView.reveal(this.topNode, { select: false });
return this.topNode;
}
getRootNode(): ExplainTreeItem {
Expand Down Expand Up @@ -119,7 +119,7 @@ export class ExplainTreeItem extends TreeItem {
private children: ExplainTreeItem[];

constructor(node: ExplainNode) {
super(node.title, node.childrenNodes > 0 ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.None);
super(node.title, node.children.length > 0 ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.None);
this.explainNode = node;
this.contextValue = `explainTreeItem`;

Expand Down
Loading
Loading