Skip to content

Commit

Permalink
fix: lineage components (#1311)
Browse files Browse the repository at this point in the history
* fix: names and types

* WIP

* WIP
  • Loading branch information
AdiGajbhiye authored Jul 18, 2024
1 parent 2df32ef commit 1aa310c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/altimate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ interface SQLLineageRequest {
session_id: string;
}

export type Details = Record<
export type SqlLineageDetails = Record<
string,
{
name: string;
Expand All @@ -81,9 +81,9 @@ export type Details = Record<
columns: { name: string; datatype?: string; expression?: string }[];
}
>;
type StaticLineageResponse = {
type SqlLineageResponse = {
tableEdges: [string, string][];
details: Details;
details: SqlLineageDetails;
nodePositions?: Record<string, [number, number]>;
};

Expand Down Expand Up @@ -885,7 +885,7 @@ export class AltimateRequest {
}

async sqlLineage(req: SQLLineageRequest) {
return this.fetch<StaticLineageResponse>("dbt/v3/sql_lineage", {
return this.fetch<SqlLineageResponse>("dbt/v3/sql_lineage", {
method: "POST",
body: JSON.stringify(req),
});
Expand Down
2 changes: 1 addition & 1 deletion src/webview_provider/queryResultPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class QueryResultPanel extends AltimateWebviewProvider {
);
}

private async checkIfWebviewReady() {
async checkIfWebviewReady() {
return new Promise<void>((resolve) => {
const interval = setInterval(() => {
if (this.isWebviewReady) {
Expand Down
16 changes: 6 additions & 10 deletions src/webview_provider/sqlLineagePanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ProgressLocation,
TextEditor,
} from "vscode";
import { AltimateRequest, Details, ModelNode } from "../altimate";
import { AltimateRequest, SqlLineageDetails, ModelNode } from "../altimate";
import { DBTProjectContainer } from "../manifest/dbtProjectContainer";
import { ManifestCacheProjectAddedEvent } from "../manifest/event/manifestCacheChangedEvent";
import { extendErrorWithSupportLinks, provideSingleton } from "../utils";
Expand All @@ -28,7 +28,7 @@ import { UsersService } from "../services/usersService";

type SQLLineage = {
tableEdges: [string, string][];
details: Details;
details: SqlLineageDetails;
nodePositions?: Record<string, [number, number]>;
errorMessage?: undefined;
};
Expand Down Expand Up @@ -190,8 +190,7 @@ export class SQLLineagePanel
});
const { details, nodePositions } = response;

const nodeMapping: Record<string, { nodeType: string; nodeId: string }> =
{};
const nodeMapping: Record<string, { nodeId: string; type: string }> = {};
for (const modelId of modelsToFetch) {
const splits = modelId.split(".");
if (splits[0] === "source") {
Expand All @@ -200,7 +199,7 @@ export class SQLLineagePanel
if (_source) {
for (const key in details) {
if (details[key].type === "table" && key.toLowerCase() === _table) {
nodeMapping[key] = { nodeType: "source", nodeId: modelId };
nodeMapping[key] = { nodeId: modelId, type: "source" };
break;
}
}
Expand All @@ -214,19 +213,16 @@ export class SQLLineagePanel
details[key].type === "table" &&
key.toLowerCase() === _node.alias.toLowerCase()
) {
nodeMapping[key] = {
nodeType: _node.resource_type,
nodeId: modelId,
};
nodeMapping[key] = { nodeId: modelId, type: _node.resource_type };
break;
}
}
continue;
}
}
nodeMapping[modelName] = {
nodeType: currNode.resource_type,
nodeId: currNode.uniqueId,
type: currNode.resource_type,
};
const FINAL_SELECT = "__final_select__";
const tableEdges = response.tableEdges.map(
Expand Down
8 changes: 4 additions & 4 deletions webview_panels/src/modules/lineage/LineageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const LineageView = (): JSX.Element | null => {
return null;
}

const lineageType = renderNode.details ? "static" : "dynamic";
const lineageType = renderNode.details ? "sql" : "dynamic";

return (
<div className={styles.lineageView}>
Expand All @@ -154,10 +154,10 @@ const LineageView = (): JSX.Element | null => {
<div className={styles.lineageWrap}>
<Lineage
theme={theme}
renderNode={renderNode}
dynamicLineage={renderNode}
lineageType={lineageType}
staticLineage={
lineageType === "static"
sqlLineage={
lineageType === "sql"
? (renderNode as StaticLineageProps)
: undefined
}
Expand Down

0 comments on commit 1aa310c

Please sign in to comment.