Пример #1
0
def invalid_source_fail_unless_test(node, target_name, target_table_name,
                                    disabled):
    if node.resource_type == NodeType.Test:
        msg = get_source_not_found_or_disabled_msg(node, target_name,
                                                   target_table_name, disabled)
        if disabled:
            logger.debug(warning_tag(msg))
        else:
            warn_or_error(msg, log_fmt=warning_tag('{}'))
    else:
        source_target_not_found(node,
                                target_name,
                                target_table_name,
                                disabled=disabled)
Пример #2
0
    def warn_for_unused_resource_config_paths(
        self,
        resource_fqns: Mapping[str, PathSet],
        disabled: PathSet,
    ) -> None:
        unused = self.get_unused_resource_config_paths(resource_fqns, disabled)
        if len(unused) == 0:
            return

        msg = UNUSED_RESOURCE_CONFIGURATION_PATH_MESSAGE.format(
            len(unused), '\n'.join('- {}'.format('.'.join(u)) for u in unused))

        warn_or_error(msg, log_fmt=warning_tag('{}'))
Пример #3
0
    def warn_unused(self) -> None:
        unused_tables: Dict[SourceKey, Optional[Set[str]]] = {}
        for patch in self.results.source_patches.values():
            key = (patch.overrides, patch.name)
            if key not in self.patches_used:
                unused_tables[key] = None
            elif patch.tables is not None:
                table_patches = {t.name for t in patch.tables}
                unused = table_patches - self.patches_used[key]
                # don't add unused tables, the
                if unused:
                    # because patches are required to be unique, we can safely
                    # write without looking
                    unused_tables[key] = unused

        if unused_tables:
            msg = self.get_unused_msg(unused_tables)
            warn_or_error(msg, log_fmt=ui.warning_tag('{}'))
Пример #4
0
    def check_modified(
        self,
        old: Optional[SelectorTarget],
        new: SelectorTarget,
    ) -> bool:
        # check if there are any changes in macros, if so, log a warning the
        # first time
        if self.macros_were_modified is None:
            self.macros_were_modified = self._macros_modified()
            if self.macros_were_modified:
                log_str = ', '.join(self.macros_were_modified)
                logger.warning(
                    warning_tag(
                        f'During a state comparison, dbt detected a change in '
                        f'macros. This will not be marked as a modification. Some '
                        f'macros: {log_str}'))

        return not new.same_contents(old)  # type: ignore