dbt-selly/dbt-env/lib/python3.8/site-packages/dbt/parser/data_test.py

27 lines
871 B
Python
Raw Normal View History

2022-03-22 15:13:27 +00:00
from dbt.contracts.graph.parsed import ParsedDataTestNode
from dbt.node_types import NodeType
from dbt.parser.base import SimpleSQLParser
from dbt.parser.search import FileBlock
from dbt.utils import get_pseudo_test_path
class DataTestParser(SimpleSQLParser[ParsedDataTestNode]):
def parse_from_dict(self, dct, validate=True) -> ParsedDataTestNode:
if validate:
ParsedDataTestNode.validate(dct)
return ParsedDataTestNode.from_dict(dct)
@property
def resource_type(self) -> NodeType:
return NodeType.Test
def transform(self, node):
if 'data' not in node.tags:
node.tags.append('data')
return node
@classmethod
def get_compiled_path(cls, block: FileBlock):
return get_pseudo_test_path(block.name, block.path.relative_path,
'data_test')