Skip to content

Commit

Permalink
merge commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AdiGajbhiye committed Oct 21, 2024
2 parents d27a9b8 + 8fec064 commit 747de74
Show file tree
Hide file tree
Showing 69 changed files with 30,290 additions and 22,701 deletions.
33 changes: 7 additions & 26 deletions dbt_core_integration.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
from decimal import Decimal
import dbt.adapters.factory

# This is critical because `get_adapter` is all over dbt-core
# as they expect a singleton adapter instance per plugin,
# so dbt-niceDatabase will have one adapter instance named niceDatabase.
# This makes sense in dbt-land where we have a single Project/Profile
# combination executed in process from start to finish or a single tenant RPC
# This doesn't fit our paradigm of one adapter per DbtProject in a multitenant server,
# so we create an adapter instance **independent** of the FACTORY cache
# and attach it directly to our RuntimeConfig which is passed through
# anywhere dbt-core needs config including in all `get_adapter` calls
dbt.adapters.factory.get_adapter = lambda config: config.adapter

import os
import threading
import uuid
Expand All @@ -37,7 +24,7 @@

import agate
import json
from dbt.adapters.factory import get_adapter_class_by_name
from dbt.adapters.factory import get_adapter, register_adapter
from dbt.config.runtime import RuntimeConfig
from dbt.flags import set_from_args
from dbt.parser.manifest import ManifestLoader, process_node
Expand Down Expand Up @@ -381,16 +368,6 @@ def __init__(
self.defer_to_prod_manifest_path = manifest_path
self.favor_state = favor_state

def get_adapter(self):
"""This inits a new Adapter which is fundamentally different than
the singleton approach in the core lib"""
adapter_name = self.config.credentials.type
adapter_type = get_adapter_class_by_name(adapter_name)
if DBT_MAJOR_VER >= 1 and DBT_MINOR_VER >= 8:
from dbt.mp_context import get_mp_context
return adapter_type(self.config, get_mp_context())
return adapter_type(self.config)

def init_config(self):
if DBT_MAJOR_VER >= 1 and DBT_MINOR_VER >= 8:
from dbt_common.context import set_invocation_context
Expand All @@ -406,16 +383,20 @@ def init_config(self):
self.config = RuntimeConfig.from_args(self.args)
if hasattr(self.config, "source_paths"):
self.config.model_paths = self.config.source_paths
if DBT_MAJOR_VER >= 1 and DBT_MINOR_VER >= 8:
from dbt.mp_context import get_mp_context
register_adapter(self.config, get_mp_context())
else:
register_adapter(self.config)

def init_project(self):
try:
self.init_config()
self.adapter = self.get_adapter()
self.adapter = get_adapter(self.config)
self.adapter.connections.set_connection_name()
if DBT_MAJOR_VER >= 1 and DBT_MINOR_VER >= 8:
from dbt.context.providers import generate_runtime_macro_context
self.adapter.set_macro_context_generator(generate_runtime_macro_context)
self.config.adapter = self.adapter
self.create_parser()
except Exception as e:
# reset project
Expand Down
16 changes: 10 additions & 6 deletions 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.46.0",
"version": "0.47.3",
"engines": {
"vscode": "^1.81.0"
},
Expand Down Expand Up @@ -97,10 +97,15 @@
"description": "Enable dbt docs collaboration.",
"default": true
},
"dbt.enableQueryBookmarks": {
"dbt.enableTeammates": {
"type": "boolean",
"description": "Enable Query history and bookmarks feature",
"default": true
"description": "Enable AltimateAI teammates feature.",
"default": false
},
"dbt.disableQueryHistory": {
"type": "boolean",
"description": "Disable Query history and bookmarks",
"default": false
},
"dbt.enableNotebooks": {
"type": "boolean",
Expand Down Expand Up @@ -696,8 +701,7 @@
"menus": {
"file/newFile": [
{
"command": "dbtPowerUser.createSqlFile",
"when": "dbt.enableQueryBookmarks == true"
"command": "dbtPowerUser.createSqlFile"
},
{
"command": "dbtPowerUser.createDatapilotNotebook",
Expand Down
2 changes: 2 additions & 0 deletions src/altimate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ export interface DocsGenerateResponse {
column_descriptions?: {
column_name: string;
column_description: string;
column_citations?: { id: string; content: string }[];
}[];
model_description?: string;
model_citations?: { id: string; content: string }[];
}

export interface DBTCoreIntegration {
Expand Down
2 changes: 1 addition & 1 deletion src/dbt_client/dbtCloudIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class DBTCloudProjectIntegration
}
if (!this.adapterType) {
// We only fetch the adapter type once, as it may impact compilation preview otherwise
this.findAdapterType();
await this.findAdapterType();
}
if (!this.version) {
await this.findVersion();
Expand Down
Loading

0 comments on commit 747de74

Please sign in to comment.