示例#1
0
def no_rejoin_models(
    manifest: Manifest,
) -> Tuple[List[Node], List[Node]]:
    rejoin_nodes = __find_rejoin_nodes(manifest.graph)

    def is_rejoin_node(node: Node):
        return node.id in rejoin_nodes

    passes, failures = partition(is_rejoin_node, manifest.nodes())
    return list(passes), list(failures)
def no_references_to_marts_from_staging(
    manifest: Manifest, ) -> Tuple[List[Node], List[Node]]:
    def staging_depends_on_mart(node: Node):
        mart_refs = [
            p for p in manifest.graph.predecessors(node.id)
            if manifest.get_node(p).is_mart
        ]
        return node.is_staging and len(list(mart_refs)) > 0

    passes, failures = partition(staging_depends_on_mart, manifest.nodes())
    return list(passes), list(failures)
示例#3
0
def no_references_to_source_from_marts(
    manifest: Manifest,
) -> Tuple[List[Node], List[Node]]:
    def mart_depends_on_source(node: Node):
        source_refs = [
            p
            for p in manifest.graph.predecessors(node.id)
            if manifest.get_node(p).is_source
        ]
        return node.is_mart and len(list(source_refs)) > 0

    passes, failures = partition(mart_depends_on_source, manifest.nodes())
    return list(passes), list(failures)
def no_references_outside_of_its_own_staging_area(
    manifest: Manifest, ) -> Tuple[List[Node], List[Node]]:
    def staging_depends_on_staging_in_another_area(node: Node):
        different_staging_area_refs = [
            p for p in manifest.graph.predecessors(node.id)
            if manifest.get_node(p).is_staging
            if not manifest.get_node(p).area == node.area
        ]
        return node.is_staging and len(list(different_staging_area_refs)) > 0

    passes, failures = partition(staging_depends_on_staging_in_another_area,
                                 manifest.nodes())
    return list(passes), list(failures)
def staging_models_have_single_source(
    manifest: Manifest,
) -> Tuple[List[Node], List[Node]]:
    def staging_model_has_more_than_one_source(node: Node):
        sources = [
            p
            for p in manifest.graph.predecessors(node.id)
            if manifest.get_node(p).is_source
        ]
        return node.is_staging and len(list(sources)) > 1

    passes, failures = partition(
        staging_model_has_more_than_one_source, manifest.nodes()
    )
    return list(passes), list(failures)
def no_orphaned_models(manifest: Manifest) -> Tuple[List[Node], List[Node]]:
    """
    return [
        node for node in dbt_manifest_file['nodes'].values()
        if is_staging(node) or is_mart(node)
        if not node['depends_on']['nodes']
    ]
    """

    def is_orphan(node: Node) -> bool:
        dependencies = list(manifest.graph.predecessors(node.id))
        return (node.is_staging or node.is_mart) and len(dependencies) < 1

    passes, failures = partition(is_orphan, manifest.nodes())
    return list(passes), list(failures)
示例#7
0
def no_owner_on_physical_models(
        manifest: Manifest) -> Tuple[List[Node], List[Node]]:
    passes, failures = partition(
        lambda x: x.is_db_relation and __is_none_or_blank(x.owner),
        manifest.nodes())
    return list(passes), list(failures)
示例#8
0
def no_disabled_models(manifest: Manifest) -> Tuple[List[Node], List[Node]]:
    passes, failures = partition(lambda x: not x.is_enabled, manifest.nodes())
    return list(passes), list(failures)