Exemplo n.º 1
0
    def _set_overriding_params_for_node(self, relation: Relation,
                                        configs: Configuration) -> Relation:
        """Finds and applies specific params from config.

        If multiple conflicting specific params are found they will be applied in descending order from the originating replica file.

        Args:
            relation: A :class:`Relation <snowshu.core.models.relation.Relation>` to be tested for specific configs.
            configs: :class:`Configuration <snowshu.core.configuration_parser.Configuration>` object to search for matches and specified params.
        Returns:
            The :class:`Relation <snowshu.core.models.relation.Relation>` with all updated params applied.
        """
        for pattern in configs.specified_relations:
            if single_full_pattern_match(relation, pattern):
                for attr in (
                        'unsampled',
                        'include_outliers',
                ):
                    pattern_val = getattr(pattern, attr, None)
                    relation.__dict__[
                        attr] = pattern_val if pattern_val is not None else relation.__dict__[
                            attr]

                if getattr(pattern, 'sampling', None) is not None:
                    relation.sampling = pattern.sampling
        return relation

        approved_specified_patterns = [
            dict(database=r.database_pattern,
                 schema=r.schema_pattern,
                 name=r.relation_pattern) for r in config.specified_relations
        ]
Exemplo n.º 2
0
 def _set_globals_for_node(self, relation: Relation,
                           configs: Configuration) -> Relation:
     """Sets the initial (default) node values from the config
         
     ARGS:
         relation: the :class:`Relation <snowshu.core.models.relation>` to set values of.
         configs: the :class"`Configuration <snowshu.core.configuration_parser.Configuration` object to derive default values from.
     
     Returns:
         The updated :class:`Relation <snowshu.core.models.relation>`
     """
     relation.sampling = configs.sampling
     relation.include_outliers = configs.include_outliers
     relation.max_number_of_outliers = configs.max_number_of_outliers
     return relation
Exemplo n.º 3
0
def stub_out_sampling(rel: Relation) -> Relation:
    rel.sampling = DefaultSampling()
    rel.sampling.sample_method = BernoulliSampleMethod(1500, units='rows')
    return rel