-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first pass: move Macro to dbt/artifacts
- Loading branch information
1 parent
ad723a6
commit ae2b362
Showing
5 changed files
with
63 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from dataclasses import dataclass | ||
from dbt_common.dataclass_schema import dbtClassMixin | ||
from dbt_common.contracts.util import Replaceable | ||
from typing import Optional | ||
|
||
|
||
@dataclass | ||
class Docs(dbtClassMixin, Replaceable): | ||
show: bool = True | ||
node_color: Optional[str] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from dataclasses import dataclass, field | ||
import time | ||
from typing import Literal, List, Dict, Optional, Any | ||
|
||
from dbt_common.contracts.util import Replaceable | ||
from dbt_common.dataclass_schema import dbtClassMixin | ||
from dbt.artifacts.resources.base import BaseArtifactNode | ||
from dbt.artifacts.resources.types import NodeType, ModelLanguage | ||
from dbt.artifacts.resources.v1.docs import Docs | ||
|
||
|
||
@dataclass | ||
class MacroArgument(dbtClassMixin): | ||
name: str | ||
type: Optional[str] = None | ||
description: str = "" | ||
|
||
|
||
@dataclass | ||
class MacroDependsOn(dbtClassMixin, Replaceable): | ||
macros: List[str] = field(default_factory=list) | ||
|
||
# 'in' on lists is O(n) so this is O(n^2) for # of macros | ||
def add_macro(self, value: str): | ||
if value not in self.macros: | ||
self.macros.append(value) | ||
|
||
|
||
@dataclass | ||
class Macro(BaseArtifactNode): | ||
macro_sql: str | ||
resource_type: Literal[NodeType.Macro] | ||
depends_on: MacroDependsOn = field(default_factory=MacroDependsOn) | ||
description: str = "" | ||
meta: Dict[str, Any] = field(default_factory=dict) | ||
docs: Docs = field(default_factory=Docs) | ||
patch_path: Optional[str] = None | ||
arguments: List[MacroArgument] = field(default_factory=list) | ||
created_at: float = field(default_factory=lambda: time.time()) | ||
supported_languages: Optional[List[ModelLanguage]] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters