Skip to content

Commit

Permalink
Merge branch 'master' into feat/lineage-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
AdiGajbhiye authored Oct 2, 2024
2 parents ce8762d + 20ca78d commit d27a9b8
Show file tree
Hide file tree
Showing 28 changed files with 3,780 additions and 8,235 deletions.
11,097 changes: 3,283 additions & 7,814 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"bugs": {
"url": "https://github.com/AltimateAI/vscode-dbt-power-user/issues"
},
"version": "0.45.2",
"version": "0.46.0",
"engines": {
"vscode": "^1.81.0"
},
Expand Down
40 changes: 29 additions & 11 deletions src/autocompletion_provider/modelAutocompletionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,37 @@ export class ModelAutocompletionProvider
event.added?.forEach((added) => {
const project = added.project;
const projectName = project.getProjectName();
const models = added.nodeMetaMap.entries();
const models = added.nodeMetaMap.nodes();
const autocompleteItems = Array.from(models)
.filter(
(model) => model.resource_type !== DBTProject.RESOURCE_TYPE_ANALYSIS,
)
.map((model) => ({
projectName,
packageName: model.package_name,
// TODO: fix this autocomplete to support for model version
modelName: model.name,
}));

const uniqueItems: Record<
string,
{
projectName: string;
packageName: string;
modelName: string;
}
> = {};

for (const item of autocompleteItems) {
const key = `${item.projectName}|${item.packageName}|${item.modelName}`;
if (!uniqueItems[key]) {
uniqueItems[key] = item;
}
}

this.modelAutocompleteMap.set(
added.project.projectRoot.fsPath,
Array.from(models)
.filter(
([key, model]) =>
model.resource_type !== DBTProject.RESOURCE_TYPE_ANALYSIS,
)
.map(([key, model]) => ({
projectName,
packageName: model.package_name,
modelName: key,
})),
Object.values(uniqueItems),
);
});
event.removed?.forEach((removed) => {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ export class VSCodeCommands implements Disposable {
return;
}
const { nodeMetaMap } = event;
const model = nodeMetaMap.get(modelName);
const model = nodeMetaMap.lookupByBaseName(modelName);
if (!model?.path) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/sqlToModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class SqlToModel {
return;
}
const { nodeMetaMap, sourceMetaMap } = event;
const allmodels = Array.from(nodeMetaMap.values());
const allmodels = Array.from(nodeMetaMap.nodes());
const allsources = Array.from(sourceMetaMap.values());

const fileText = activedoc.document.getText();
Expand Down
2 changes: 1 addition & 1 deletion src/commands/tests/missingSchemaTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class MissingSchemaTest implements AltimateScanStep {
return;
}
const { nodeMetaMap } = projectEventMap;
for (const [key, value] of nodeMetaMap) {
for (const value of nodeMetaMap.nodes()) {
// blacklisting node types.. should we instead whitelist just models and sources?
if (
// TODO - need to filter out only models here but the resource type isnt available
Expand Down
2 changes: 1 addition & 1 deletion src/commands/tests/staleModelColumnTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class StaleModelColumnTest implements AltimateScanStep {
return;
}
const { nodeMetaMap } = projectEventMap;
for (const [key, value] of nodeMetaMap) {
for (const value of nodeMetaMap.nodes()) {
if (value.config.materialized === "ephemeral") {
// ephemeral models by nature wont be materialized so we cant verify if they are stale.
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/tests/undocumentedModelColumnTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class UndocumentedModelColumnTest implements AltimateScanStep {
return;
}
const { nodeMetaMap } = projectEventMap;
for (const [key, value] of nodeMetaMap) {
for (const value of nodeMetaMap.nodes()) {
if (
(scanResults["missingDoc"] !== undefined &&
scanResults["missingDoc"].has(value.uniqueId)) ||
Expand Down
2 changes: 1 addition & 1 deletion src/commands/tests/unmaterializedModelTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class UnmaterializedModelTest implements AltimateScanStep {
return;
}
const { nodeMetaMap } = projectEventMap;
for (const [key, value] of nodeMetaMap) {
for (const value of nodeMetaMap.nodes()) {
if (value.config.materialized === "ephemeral") {
// ephemeral models by nature wont be materialized.
// seeds should be materialized so that other features
Expand Down
2 changes: 1 addition & 1 deletion src/commands/validateSql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class ValidateSql {
return;
}
const { graphMetaMap, nodeMetaMap } = event;
const node = nodeMetaMap.get(modelName);
const node = nodeMetaMap.lookupByBaseName(modelName);
if (!node) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/comment_provider/conversationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export class ConversationProvider implements Disposable {
return;
}

const currentNode = event.nodeMetaMap.get(resourceName);
const currentNode = event.nodeMetaMap.lookupByBaseName(resourceName);
// For model
if (currentNode) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/definition_provider/modelDefinitionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class ModelDefinitionProvider implements DefinitionProvider, Disposable {
if (nodeMap === undefined) {
return;
}
const location = nodeMap.get(modelName);
const location = nodeMap.lookupByBaseName(modelName);
if (location && location.path) {
return new Location(Uri.file(location.path), new Range(0, 0, 999, 999));
}
Expand Down
7 changes: 6 additions & 1 deletion src/domain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as path from "path";

export type NodeMetaMap = Map<string, NodeMetaData>;
export type MacroMetaMap = Map<string, MacroMetaData>;
export type MetricMetaMap = Map<string, MetricMetaData>;
export type SourceMetaMap = Map<string, SourceMetaData>;
Expand All @@ -10,6 +9,12 @@ export type DocMetaMap = Map<string, DocMetaData>;
export type NodeMetaType = NodeMetaData;
export type SourceMetaType = SourceTable;

export interface NodeMetaMap {
lookupByBaseName(modelBaseName: string): NodeMetaData | undefined;
lookupByUniqueId(uniqueId: string): NodeMetaData | undefined;
nodes(): Iterable<NodeMetaData>;
}

export interface MacroMetaData {
path: string | undefined; // in dbt cloud, packages are not downloaded locally
line: number;
Expand Down
2 changes: 1 addition & 1 deletion src/hover_provider/macroHoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class MacroHoverProvider implements HoverProvider, Disposable {
nodeMetaMap: NodeMetaMap,
) {
const referencedBy: (MacroMetaData | NodeMetaData)[] = [];
const allNodes = [...macroMetaMap.values(), ...nodeMetaMap.values()];
const allNodes = [...macroMetaMap.values(), ...nodeMetaMap.nodes()];

allNodes.forEach((node) => {
if (node.depends_on.macros.includes(macroMetaName)) {
Expand Down
2 changes: 1 addition & 1 deletion src/hover_provider/modelHoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class ModelHoverProvider implements HoverProvider, Disposable {
if (nodeMap === undefined) {
return;
}
const node = nodeMap.get(modelName);
const node = nodeMap.lookupByBaseName(modelName);
if (node) {
return generateHoverMarkdownString(node, "ref");
}
Expand Down
2 changes: 1 addition & 1 deletion src/hover_provider/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const generateMacroHoverMarkdown = (
[...event.macroMetaMap.values()].find((macro) => macro.uniqueId === m),
) || []),
...(node.depends_on.nodes?.map((m) =>
[...event.nodeMetaMap.values()].find((macro) => macro.uniqueId === m),
[...event.nodeMetaMap.nodes()].find((macro) => macro.uniqueId === m),
) || []),
];
addSeparator(content);
Expand Down
Loading

0 comments on commit d27a9b8

Please sign in to comment.