Skip to content

Commit

Permalink
Merge pull request #2312 from fishtown-analytics/feature/dbt-project-v2
Browse files Browse the repository at this point in the history
dbt project v2
  • Loading branch information
beckjake authored Apr 22, 2020
2 parents c05b45b + 5ed5693 commit 616b32e
Show file tree
Hide file tree
Showing 133 changed files with 3,002 additions and 1,522 deletions.
2 changes: 1 addition & 1 deletion core/dbt/adapters/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
SchemaSearchMap,
)
from dbt.adapters.base.column import Column # noqa
from dbt.adapters.base.impl import BaseAdapter # noqa
from dbt.adapters.base.impl import AdapterConfig, BaseAdapter # noqa
from dbt.adapters.base.plugin import AdapterPlugin # noqa
13 changes: 10 additions & 3 deletions core/dbt/adapters/base/impl.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import abc
from concurrent.futures import as_completed, Future
from contextlib import contextmanager
from dataclasses import dataclass
from datetime import datetime
from typing import (
Optional, Tuple, Callable, Iterable, FrozenSet, Type, Dict, Any, List,
Mapping, Iterator, Union, Set
Optional, Tuple, Callable, Iterable, Type, Dict, Any, List, Mapping,
Iterator, Union, Set
)

import agate
Expand All @@ -23,6 +24,7 @@
from dbt.contracts.graph.compiled import CompileResultNode, CompiledSeedNode
from dbt.contracts.graph.manifest import Manifest
from dbt.contracts.graph.parsed import ParsedSeedNode
from dbt.contracts.graph.model_config import BaseConfig
from dbt.exceptions import warn_or_error
from dbt.node_types import NodeType
from dbt.logger import GLOBAL_LOGGER as logger
Expand Down Expand Up @@ -105,6 +107,11 @@ def _relation_name(rel: Optional[BaseRelation]) -> str:
return str(rel)


@dataclass
class AdapterConfig(BaseConfig):
pass


class BaseAdapter(metaclass=AdapterMeta):
"""The BaseAdapter provides an abstract base class for adapters.
Expand Down Expand Up @@ -147,7 +154,7 @@ class BaseAdapter(metaclass=AdapterMeta):

# A set of clobber config fields accepted by this adapter
# for use in materializations
AdapterSpecificConfigs: FrozenSet[str] = frozenset()
AdapterSpecificConfigs: Type[AdapterConfig] = AdapterConfig

def __init__(self, config):
self.config = config
Expand Down
12 changes: 11 additions & 1 deletion core/dbt/adapters/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.contracts.connection import Credentials, AdapterRequiredConfig

from dbt.adapters.base.impl import BaseAdapter
from dbt.adapters.base.impl import BaseAdapter, AdapterConfig
from dbt.adapters.base.plugin import AdapterPlugin


Expand Down Expand Up @@ -40,6 +40,12 @@ def get_relation_class_by_name(self, name: str) -> Type[BaseRelation]:
adapter = self.get_adapter_class_by_name(name)
return adapter.Relation

def get_config_class_by_name(
self, name: str
) -> Type[AdapterConfig]:
adapter = self.get_adapter_class_by_name(name)
return adapter.AdapterSpecificConfigs

def load_plugin(self, name: str) -> Type[Credentials]:
# this doesn't need a lock: in the worst case we'll overwrite PACKAGES
# and adapter_type entries with the same value, as they're all
Expand Down Expand Up @@ -137,6 +143,10 @@ def get_adapter_class_by_name(name: str) -> Type[BaseAdapter]:
return FACTORY.get_adapter_class_by_name(name)


def get_config_class_by_name(name: str) -> Type[AdapterConfig]:
return FACTORY.get_config_class_by_name(name)


def get_relation_class_by_name(name: str) -> Type[BaseRelation]:
return FACTORY.get_relation_class_by_name(name)

Expand Down
1 change: 0 additions & 1 deletion core/dbt/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from dbt.context.providers import generate_runtime_model
from dbt.contracts.graph.manifest import Manifest
import dbt.contracts.project
import dbt.exceptions
import dbt.flags
import dbt.config
Expand Down
1 change: 0 additions & 1 deletion core/dbt/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
from .profile import Profile, PROFILES_DIR, read_user_config # noqa
from .project import Project # noqa
from .runtime import RuntimeConfig, UnsetProfileConfig # noqa
from .renderer import ConfigRenderer # noqa
12 changes: 6 additions & 6 deletions core/dbt/config/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from dbt.logger import GLOBAL_LOGGER as logger
from dbt.utils import coerce_dict_str

from .renderer import ConfigRenderer
from .renderer import ProfileRenderer

DEFAULT_THREADS = 1
DEFAULT_PROFILES_DIR = os.path.join(os.path.expanduser('~'), '.dbt')
Expand Down Expand Up @@ -240,7 +240,7 @@ def render_profile(
raw_profile: Dict[str, Any],
profile_name: str,
target_override: Optional[str],
renderer: ConfigRenderer,
renderer: ProfileRenderer,
) -> Tuple[str, Dict[str, Any]]:
"""This is a containment zone for the hateful way we're rendering
profiles.
Expand Down Expand Up @@ -268,15 +268,15 @@ def render_profile(
raw_profile, profile_name, target_name
)

profile_data = renderer.render_profile_data(raw_profile_data)
profile_data = renderer.render_data(raw_profile_data)
return target_name, profile_data

@classmethod
def from_raw_profile_info(
cls,
raw_profile: Dict[str, Any],
profile_name: str,
renderer: ConfigRenderer,
renderer: ProfileRenderer,
user_cfg: Optional[Dict[str, Any]] = None,
target_override: Optional[str] = None,
threads_override: Optional[int] = None,
Expand Down Expand Up @@ -330,7 +330,7 @@ def from_raw_profiles(
cls,
raw_profiles: Dict[str, Any],
profile_name: str,
renderer: ConfigRenderer,
renderer: ProfileRenderer,
target_override: Optional[str] = None,
threads_override: Optional[int] = None,
) -> 'Profile':
Expand Down Expand Up @@ -380,7 +380,7 @@ def from_raw_profiles(
def render_from_args(
cls,
args: Any,
renderer: ConfigRenderer,
renderer: ProfileRenderer,
project_profile_name: Optional[str],
) -> 'Profile':
"""Given the raw profiles as read from disk and the name of the desired
Expand Down
Loading

0 comments on commit 616b32e

Please sign in to comment.