def test_passing_upstream_and_product_in_postgres(pg_client, db_credentials): dag = DAG() client = SQLAlchemyClient(db_credentials['uri']) dag.clients[SQLScript] = client dag.clients[PostgresRelation] = client conn = pg_client.connection cur = conn.cursor() cur.execute('drop table if exists series;') conn.commit() conn.close() ta_t = """begin; drop table if exists {{product}}; create table {{product}} as select * from generate_series(0, 15) as n; commit;""" ta_rel = PostgresRelation((None, 'series', 'table')) ta = SQLScript(ta_t, ta_rel, dag, 'ta') dag.build() assert ta_rel.exists()
def test_passing_upstream_and_product_in_postgres(pg_client_and_schema): client, _ = pg_client_and_schema dag = DAG() dag.clients[SQLScript] = client dag.clients[PostgresRelation] = client client.execute('drop table if exists series;') ta_t = """begin; drop table if exists {{product}}; create table {{product}} as select * from generate_series(0, 15) as n; commit;""" ta_rel = PostgresRelation((None, 'series', 'table')) SQLScript(ta_t, ta_rel, dag, 'ta') dag.build() assert ta_rel.exists()
def test_exists_with_empty_schema(pg_client_and_schema): client, schema = pg_client_and_schema product = PostgresRelation(('data', 'table'), client) assert product.exists()