use of com.facebook.presto.spi.ConnectorMaterializedViewDefinition.TableColumn in project presto by prestodb.
the class MaterializedViewColumnMappingExtractor method getColumnMappings.
private static Map<String, Map<SchemaTableName, String>> getColumnMappings(Analysis analysis, Map<TableColumn, Set<TableColumn>> columnMappings) {
checkState(analysis.getStatement() instanceof CreateMaterializedView, "Only support the computation of column mappings when analyzing CreateMaterializedView");
ImmutableMap.Builder<String, Map<SchemaTableName, String>> fullColumnMappings = ImmutableMap.builder();
Map<String, TableColumn> originalColumnMappings = getOriginalColumnsFromAnalysis(analysis);
for (Map.Entry<String, TableColumn> columnMapping : originalColumnMappings.entrySet()) {
String viewColumn = columnMapping.getKey();
TableColumn originalBaseColumn = columnMapping.getValue();
Map<SchemaTableName, String> fullBaseColumns = columnMappings.getOrDefault(originalBaseColumn, ImmutableSet.of(originalBaseColumn)).stream().collect(toImmutableMap(e -> e.getTableName(), e -> e.getColumnName()));
fullColumnMappings.put(viewColumn, fullBaseColumns);
}
return fullColumnMappings.build();
}
use of com.facebook.presto.spi.ConnectorMaterializedViewDefinition.TableColumn in project presto by prestodb.
the class MaterializedViewColumnMappingExtractor method tryGetOriginalTableColumn.
private static Optional<TableColumn> tryGetOriginalTableColumn(Field field) {
if (field.getOriginTable().isPresent() && field.getOriginColumnName().isPresent()) {
SchemaTableName table = toSchemaTableName(field.getOriginTable().get());
String column = field.getOriginColumnName().get();
return Optional.of(new TableColumn(table, column, true));
}
return Optional.empty();
}
Aggregations