Example #1
0
def test_materialized_from_obj_maybe_materialize(db_engine_with_events_table):
    from_obj = FromObj(from_obj="events",
                       name="myquery",
                       knowledge_date_column='event_date')
    from_obj.should_materialize = lambda: True
    from_obj.maybe_materialize(db_engine_with_events_table)
    assert table_exists(from_obj.table, db_engine_with_events_table)
Example #2
0
    def preprocess_aggregation(self, aggregation):
        create_schema = aggregation.get_create_schema()

        if create_schema is not None:
            with self.db_engine.begin() as conn:
                conn.execute(create_schema)

        if self.materialize_subquery_fromobjs:
            # materialize from obj
            from_obj = FromObj(
                from_obj=aggregation.from_obj.text,
                name=f"{aggregation.schema}.{aggregation.prefix}",
                knowledge_date_column=aggregation.date_column)
            from_obj.maybe_materialize(self.db_engine)
            aggregation.from_obj = from_obj.table
        return aggregation