(self, relation: BaseRelation)
Ensure that the target relation is valid, by making sure it has the
        expected columns.

        :param Relation relation: The relation to check
        :raises CompilationException: If the columns are
            incorrect.
Ensure that the target relation is valid, by making sure it has the
        expected columns.
Ensure that the target relation is valid by making sure it has the expected columns .
def valid_snapshot_target(self, relation: BaseRelation) -> None:
        """Ensure that the target relation is valid, by making sure it has the
        expected columns.

        :param Relation relation: The relation to check
        :raises CompilationException: If the columns are
            incorrect.
        """
        if not isinstance(relation, self.Relation):
            invalid_type_error(
                method_name='valid_snapshot_target',
                arg_name='relation',
                got_value=relation,
                expected_type=self.Relation)

        columns = self.get_columns_in_relation(relation)
        names = set(c.name.lower() for c in columns)
        expanded_keys = ('scd_id', 'valid_from', 'valid_to')
        extra = []
        missing = []
        for legacy in expanded_keys:
            desired = 'dbt_' + legacy
            if desired not in names:
                missing.append(desired)
                if legacy in names:
                    extra.append(legacy)

        if missing:
            if extra:
                msg = (
                    'Snapshot target has ("{}") but not ("{}") - is it an '
                    'unmigrated previous version archive?'
                    .format('", "'.join(extra), '", "'.join(missing))
                )
            else:
                msg = (
                    'Snapshot target is not a snapshot table (missing "{}")'
                    .format('", "'.join(missing))
                )
            raise_compiler_error(msg)
def valid_snapshot_target ( self , relation : BaseRelation ) -> None : if not isinstance ( relation , self . Relation ) : invalid_type_error ( method_name = 'valid_snapshot_target' , arg_name = 'relation' , got_value = relation , expected_type = self . Relation ) columns = self . get_columns_in_relation ( relation ) names = set ( c . name . lower ( ) for c in columns ) expanded_keys = ( 'scd_id' , 'valid_from' , 'valid_to' ) extra = [ ] missing = [ ] for legacy in expanded_keys : desired = 'dbt_' + legacy if desired not in names : missing . append ( desired ) if legacy in names : extra . append ( legacy ) if missing : if extra : msg = ( 'Snapshot target has ("{}") but not ("{}") - is it an ' 'unmigrated previous version archive?' . format ( '", "' . join ( extra ) , '", "' . join ( missing ) ) ) else : msg = ( 'Snapshot target is not a snapshot table (missing "{}")' . format ( '", "' . join ( missing ) ) ) raise_compiler_error ( msg )