use of com.facebook.presto.sql.analyzer.MaterializedViewCandidateExtractor in project presto by prestodb.
the class MaterializedViewOptimizationRewriteUtils method optimizeQueryUsingMaterializedView.
public static Query optimizeQueryUsingMaterializedView(Metadata metadata, Session session, SqlParser sqlParser, AccessControl accessControl, Query node) {
MaterializedViewCandidateExtractor materializedViewCandidateExtractor = new MaterializedViewCandidateExtractor(session, metadata);
materializedViewCandidateExtractor.process(node);
Set<QualifiedObjectName> materializedViewCandidates = materializedViewCandidateExtractor.getMaterializedViewCandidates();
// TODO: Refactor query optimization code https://github.com/prestodb/presto/issues/16759
for (QualifiedObjectName candidate : materializedViewCandidates) {
Query optimizedQuery = getQueryWithMaterializedViewOptimization(metadata, session, sqlParser, accessControl, node, candidate);
if (node != optimizedQuery) {
MaterializedViewStatus materializedViewStatus = metadata.getMaterializedViewStatus(session, candidate);
if (materializedViewStatus.isFullyMaterialized() || materializedViewStatus.isPartiallyMaterialized()) {
session.getRuntimeStats().addMetricValue(OPTIMIZED_WITH_MATERIALIZED_VIEW, 1);
return optimizedQuery;
}
}
}
return node;
}
Aggregations