Search in sources :

Example 1 with MaterializedViewQueryOptimizer

use of com.facebook.presto.sql.analyzer.MaterializedViewQueryOptimizer in project presto by prestodb.

the class MaterializedViewOptimizationRewriteUtils method getQueryWithMaterializedViewOptimization.

private static Query getQueryWithMaterializedViewOptimization(Metadata metadata, Session session, SqlParser sqlParser, AccessControl accessControl, Query statement, QualifiedObjectName materializedViewQualifiedObjectName) {
    ConnectorMaterializedViewDefinition materializedView = metadata.getMaterializedView(session, materializedViewQualifiedObjectName).get();
    Table materializedViewTable = new Table(QualifiedName.of(materializedView.getTable()));
    Query materializedViewDefinition = (Query) sqlParser.createStatement(materializedView.getOriginalSql());
    return (Query) new MaterializedViewQueryOptimizer(metadata, session, sqlParser, accessControl, new RowExpressionDomainTranslator(metadata), materializedViewTable, materializedViewDefinition).rewrite(statement);
}
Also used : MaterializedViewQueryOptimizer(com.facebook.presto.sql.analyzer.MaterializedViewQueryOptimizer) Table(com.facebook.presto.sql.tree.Table) Query(com.facebook.presto.sql.tree.Query) RowExpressionDomainTranslator(com.facebook.presto.sql.relational.RowExpressionDomainTranslator) ConnectorMaterializedViewDefinition(com.facebook.presto.spi.ConnectorMaterializedViewDefinition)

Aggregations

ConnectorMaterializedViewDefinition (com.facebook.presto.spi.ConnectorMaterializedViewDefinition)1 MaterializedViewQueryOptimizer (com.facebook.presto.sql.analyzer.MaterializedViewQueryOptimizer)1 RowExpressionDomainTranslator (com.facebook.presto.sql.relational.RowExpressionDomainTranslator)1 Query (com.facebook.presto.sql.tree.Query)1 Table (com.facebook.presto.sql.tree.Table)1