def test_basic_materialized_view(selectable):
    expected_result = """
    CREATE MATERIALIZED VIEW test_view
    AS SELECT t1.id, t1.name FROM t1
    """
    view = dialect.CreateMaterializedView("test_view", selectable)
    assert clean(expected_result) == clean(compile_query(view))
def test_diststyle_materialized_view(selectable):
    expected_result = """
    CREATE MATERIALIZED VIEW test_view
    DISTSTYLE ALL
    AS SELECT t1.id, t1.name FROM t1
    """
    view = dialect.CreateMaterializedView("test_view",
                                          selectable,
                                          diststyle='ALL')
    assert clean(expected_result) == clean(compile_query(view))
def test_interleaved_sortkey_materialized_view(selectable):
    expected_result = """
    CREATE MATERIALIZED VIEW test_view
    INTERLEAVED SORTKEY (id)
    AS SELECT t1.id, t1.name FROM t1
    """
    for key in ("id", selectable.c.id):
        view = dialect.CreateMaterializedView("test_view",
                                              selectable,
                                              interleaved_sortkey=key)
        assert clean(expected_result) == clean(compile_query(view))
예제 #4
0
def test_no_backup_materialized_view(selectable, stub_redshift_dialect):
    expected_result = """
    CREATE MATERIALIZED VIEW test_view
    BACKUP NO
    AS SELECT t1.id, t1.name FROM t1
    """
    view = dialect.CreateMaterializedView("test_view",
                                          selectable,
                                          backup=False)
    assert clean(expected_result) == \
        clean(compile_query(view, stub_redshift_dialect))
예제 #5
0
def test_sortkey_materialized_view(selectable, stub_redshift_dialect):
    expected_result = """
    CREATE MATERIALIZED VIEW test_view
    SORTKEY (id)
    AS SELECT t1.id, t1.name FROM t1
    """
    for key in ("id", selectable.c.id):
        view = dialect.CreateMaterializedView("test_view",
                                              selectable,
                                              sortkey=key)
        assert clean(expected_result) == \
            clean(compile_query(view, stub_redshift_dialect))