use of com.facebook.presto.sql.analyzer.Analysis.AccessControlInfo in project presto by prestodb.
the class UtilizedColumnsAnalyzer method analyze.
public void analyze(Node node) {
UtilizedFieldsBuilderVisitor visitor = new UtilizedFieldsBuilderVisitor(analysis);
ImmutableSet.Builder<Field> utilizedFieldsBuilder = ImmutableSet.builder();
visitor.process(node, new Context(utilizedFieldsBuilder));
// Keep only the utilized fields that are actual table columns
HashMultimap<QualifiedObjectName, String> utilizedTableColumns = HashMultimap.create();
for (Field field : utilizedFieldsBuilder.build()) {
if (field.getOriginTable().isPresent() && field.getOriginColumnName().isPresent()) {
utilizedTableColumns.put(field.getOriginTable().get(), field.getOriginColumnName().get());
}
}
// For each access control, keep only the table columns that impact the final results
for (Entry<AccessControlInfo, Map<QualifiedObjectName, Set<String>>> entry : analysis.getTableColumnReferences().entrySet()) {
AccessControlInfo accessControlInfo = entry.getKey();
Map<QualifiedObjectName, Set<String>> tableColumnsForThisAccessControl = entry.getValue();
Map<QualifiedObjectName, Set<String>> utilizedTableColumnsForThisAccessControl = new HashMap<>();
for (QualifiedObjectName table : tableColumnsForThisAccessControl.keySet()) {
utilizedTableColumnsForThisAccessControl.put(table, intersection(utilizedTableColumns.get(table), tableColumnsForThisAccessControl.get(table)));
}
analysis.addUtilizedTableColumnReferences(accessControlInfo, utilizedTableColumnsForThisAccessControl);
}
}
Aggregations