def __init__(self): self.string_attribute = Attribute( name=rand_string(10), data_type=dt.VARCHAR) self.integer_attribute = Attribute( name=rand_string(10), data_type=dt.INTEGER) self.double_attribute = Attribute( name=rand_string(10), data_type=dt.DOUBLE)
def __init__(self): self.downstream_relation = Relation( name='downstream_relation', **self.rand_relation_helper()) self.upstream_relation = Relation( name='upstream_relation', **self.rand_relation_helper()) self.iso_relation = Relation( name='iso_relation', **self.rand_relation_helper()) self.birelation_left = Relation( name='birelation_left', **self.rand_relation_helper()) self.birelation_right = Relation( name='birelation_right', **self.rand_relation_helper()) self.view_relation = Relation( name='view_relation', **self.rand_relation_helper()) self.bidirectional_key_left = rand_string(10), self.bidirectional_key_right = rand_string(8), self.directional_key = rand_string(15) # update specifics self.view_relation.materialization = mz.VIEW for n in ('downstream_relation', 'upstream_relation',): self.__dict__[n].attributes = [ Attribute(self.directional_key, dt.INTEGER)] self.birelation_right.attributes = [ Attribute(self.bidirectional_key_right, dt.VARCHAR)] self.birelation_left.attributes = [ Attribute(self.bidirectional_key_left, dt.VARCHAR)] for r in ('downstream_relation', 'upstream_relation', 'iso_relation', 'birelation_left', 'birelation_right', 'view_relation',): self.__dict__[r].compiled_query = ''
def _initialize_snowshu_meta_database(self) -> None: self.create_database_if_not_exists('snowshu') self.create_schema_if_not_exists('snowshu', 'snowshu') attributes = [ Attribute('created_at', dt.TIMESTAMP_TZ), Attribute('name', dt.VARCHAR), Attribute('short_description', dt.VARCHAR), Attribute('long_description', dt.VARCHAR) ] relation = Relation("snowshu", "snowshu", "replica_meta", mz.TABLE, attributes) relation.data = pd.DataFrame([ dict(created_at=datetime.now(), name=self.replica_meta['name'], short_description=self.replica_meta['short_description'], long_description=self.replica_meta['long_description']) ]) self.create_and_load_relation(relation)
def test_get_relations_from_database(end_to_end): adapter = PostgresAdapter(replica_metadata={}) if adapter.target != "localhost": adapter._credentials.host = 'integration-test' config_patterns = [dict(database="snowshu", schema=".*", name=".*")] attributes = [ Attribute('created_at', data_types.TIMESTAMP_TZ), Attribute('config_json', data_types.JSON), Attribute('name', data_types.VARCHAR), Attribute('short_description', data_types.VARCHAR), Attribute('long_description', data_types.VARCHAR) ] relation = Relation("snowshu", "snowshu", "replica_meta", TABLE, attributes) catalog = adapter.build_catalog(config_patterns, thread_workers=1) relations = [] for rel in catalog: relations.append(rel.__dict__.items()) assert relation.__dict__.items() in relations
def __init__(self): self.downstream_relation = Relation(name='downstream_relation', **self.rand_relation_helper()) self.upstream_relation = Relation(name='upstream_relation', **self.rand_relation_helper()) self.iso_relation = Relation(name='iso_relation', **self.rand_relation_helper()) self.birelation_left = Relation(name='birelation_left', **self.rand_relation_helper()) self.birelation_right = Relation(name='birelation_right', **self.rand_relation_helper()) self.view_relation = Relation(name='view_relation', **self.rand_relation_helper()) self.downstream_wildcard_relation_1 = Relation( name='downstream_wildcard_relation_1', **self.rand_relation_helper()) self.downstream_wildcard_relation_2 = Relation( name='downstream_wildcard_relation_2', **self.rand_relation_helper()) self.upstream_wildcard_relation_1 = Relation( name='upstream_wildcard_relation_1', schema=self.downstream_wildcard_relation_1.schema, database=self.downstream_wildcard_relation_1.database, materialization=mz.TABLE, attributes=[]) self.upstream_wildcard_relation_2 = Relation( name='upstream_wildcard_relation_2', schema=self.downstream_wildcard_relation_2.schema, database=self.downstream_wildcard_relation_2.database, materialization=mz.TABLE, attributes=[]) self.parent_relation_childid_type = Relation( name='parent_relation_childid_type', **self.rand_relation_helper()) self.parent_relation_parentid = Relation( name='parent_relation_parentid', **self.rand_relation_helper()) self.child_relation_type_1 = Relation(name='child_type_1_records', **self.rand_relation_helper()) self.child_relation_type_2 = Relation(name='child_type_2_records', **self.rand_relation_helper()) self.child_relation_type_3 = Relation(name='child_type_3_records', **self.rand_relation_helper()) self.bidirectional_key_left = rand_string(10) self.bidirectional_key_right = rand_string(8) self.directional_key = rand_string(15) self.parentid_key = rand_string(15) self.childid_key = rand_string(15) self.childtype_key = rand_string(15) self.child2override_key = rand_string(20) # update specifics self.view_relation.materialization = mz.VIEW for n in ('downstream_relation', 'upstream_relation', 'downstream_wildcard_relation_1', 'downstream_wildcard_relation_2', 'upstream_wildcard_relation_1', 'upstream_wildcard_relation_2'): self.__dict__[n].attributes = [ Attribute(self.directional_key, dt.INTEGER) ] for n in ( 'child_relation_type_1', 'child_relation_type_2', 'child_relation_type_3', ): self.__dict__[n].attributes = [ Attribute(self.parentid_key, dt.VARCHAR), Attribute(self.childid_key, dt.VARCHAR) ] self.parent_relation_childid_type.attributes = [ Attribute(self.childid_key, dt.VARCHAR), Attribute(self.childtype_key, dt.VARCHAR) ] self.parent_relation_parentid.attributes = [ Attribute(self.parentid_key, dt.VARCHAR) ] self.birelation_right.attributes = [ Attribute(self.bidirectional_key_right, dt.VARCHAR) ] self.birelation_left.attributes = [ Attribute(self.bidirectional_key_left, dt.VARCHAR) ] for r in ('downstream_relation', 'upstream_relation', 'iso_relation', 'birelation_left', 'birelation_right', 'view_relation', 'downstream_wildcard_relation_1', 'downstream_wildcard_relation_2', 'upstream_wildcard_relation_1', 'upstream_wildcard_relation_2', 'child_relation_type_1', 'child_relation_type_2', 'child_relation_type_3', 'parent_relation_childid_type', 'parent_relation_parentid'): self.__dict__[r].compiled_query = ''