Search in sources :

Example 1 with RefreshMaterializedView

use of io.trino.sql.tree.RefreshMaterializedView in project trino by trinodb.

the class LogicalPlanner method planStatement.

public PlanNode planStatement(Analysis analysis, Statement statement) {
    if ((statement instanceof CreateTableAsSelect && analysis.getCreate().orElseThrow().isCreateTableAsSelectNoOp()) || statement instanceof RefreshMaterializedView && analysis.isSkipMaterializedViewRefresh()) {
        Symbol symbol = symbolAllocator.newSymbol("rows", BIGINT);
        PlanNode source = new ValuesNode(idAllocator.getNextId(), ImmutableList.of(symbol), ImmutableList.of(new Row(ImmutableList.of(new GenericLiteral("BIGINT", "0")))));
        return new OutputNode(idAllocator.getNextId(), source, ImmutableList.of("rows"), ImmutableList.of(symbol));
    }
    return createOutputPlan(planStatementWithoutOutput(analysis, statement), analysis);
}
Also used : ValuesNode(io.trino.sql.planner.plan.ValuesNode) OutputNode(io.trino.sql.planner.plan.OutputNode) PlanNode(io.trino.sql.planner.plan.PlanNode) RefreshMaterializedView(io.trino.sql.tree.RefreshMaterializedView) CreateTableAsSelect(io.trino.sql.tree.CreateTableAsSelect) Row(io.trino.sql.tree.Row) GenericLiteral(io.trino.sql.tree.GenericLiteral)

Example 2 with RefreshMaterializedView

use of io.trino.sql.tree.RefreshMaterializedView in project trino by trinodb.

the class TestSqlParser method testRefreshMaterializedView.

@Test
public void testRefreshMaterializedView() {
    assertStatement("REFRESH MATERIALIZED VIEW test", new RefreshMaterializedView(Optional.empty(), new Table(QualifiedName.of("test"))));
    assertStatement("REFRESH MATERIALIZED VIEW \"some name that contains space\"", new RefreshMaterializedView(Optional.empty(), new Table(QualifiedName.of("some name that contains space"))));
}
Also used : CreateTable(io.trino.sql.tree.CreateTable) DropTable(io.trino.sql.tree.DropTable) Table(io.trino.sql.tree.Table) TruncateTable(io.trino.sql.tree.TruncateTable) RenameTable(io.trino.sql.tree.RenameTable) RefreshMaterializedView(io.trino.sql.tree.RefreshMaterializedView) Test(org.junit.jupiter.api.Test)

Aggregations

RefreshMaterializedView (io.trino.sql.tree.RefreshMaterializedView)2 OutputNode (io.trino.sql.planner.plan.OutputNode)1 PlanNode (io.trino.sql.planner.plan.PlanNode)1 ValuesNode (io.trino.sql.planner.plan.ValuesNode)1 CreateTable (io.trino.sql.tree.CreateTable)1 CreateTableAsSelect (io.trino.sql.tree.CreateTableAsSelect)1 DropTable (io.trino.sql.tree.DropTable)1 GenericLiteral (io.trino.sql.tree.GenericLiteral)1 RenameTable (io.trino.sql.tree.RenameTable)1 Row (io.trino.sql.tree.Row)1 Table (io.trino.sql.tree.Table)1 TruncateTable (io.trino.sql.tree.TruncateTable)1 Test (org.junit.jupiter.api.Test)1