use of com.facebook.presto.common.QualifiedObjectName 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);
}
}
use of com.facebook.presto.common.QualifiedObjectName in project presto by prestodb.
the class TestMinimalFunctionality method testTableExists.
@Test
public void testTableExists() {
QualifiedObjectName name = new QualifiedObjectName("redis", "default", tableName);
transaction(queryRunner.getTransactionManager(), new AllowAllAccessControl()).singleStatement().execute(SESSION, session -> {
Optional<TableHandle> handle = queryRunner.getServer().getMetadata().getTableHandle(session, name);
assertTrue(handle.isPresent());
});
}
use of com.facebook.presto.common.QualifiedObjectName in project presto by prestodb.
the class QueryAssertions method copyTable.
private static void copyTable(QueryRunner queryRunner, String sourceCatalog, String sourceSchema, String sourceTable, Session session, boolean ifNotExists) {
QualifiedObjectName table = new QualifiedObjectName(sourceCatalog, sourceSchema, sourceTable);
copyTable(queryRunner, table, session, ifNotExists);
}
use of com.facebook.presto.common.QualifiedObjectName in project presto by prestodb.
the class TestHiveIntegrationSmokeTest method getTableMetadata.
private TableMetadata getTableMetadata(String catalog, String schema, String tableName) {
Session session = getSession();
Metadata metadata = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getMetadata();
return transaction(getQueryRunner().getTransactionManager(), getQueryRunner().getAccessControl()).readOnly().execute(session, transactionSession -> {
Optional<TableHandle> tableHandle = metadata.getTableHandle(transactionSession, new QualifiedObjectName(catalog, schema, tableName));
assertTrue(tableHandle.isPresent());
return metadata.getTableMetadata(transactionSession, tableHandle.get());
});
}
use of com.facebook.presto.common.QualifiedObjectName in project presto by prestodb.
the class LogicalPlanner method createTableCreationPlan.
private RelationPlan createTableCreationPlan(Analysis analysis, Query query) {
QualifiedObjectName destination = analysis.getCreateTableDestination().get();
RelationPlan plan = createRelationPlan(analysis, query);
ConnectorTableMetadata tableMetadata = createTableMetadata(destination, getOutputTableColumns(plan, analysis.getColumnAliases()), analysis.getCreateTableProperties(), analysis.getParameters(), analysis.getCreateTableComment());
Optional<NewTableLayout> newTableLayout = metadata.getNewTableLayout(session, destination.getCatalogName(), tableMetadata);
Optional<NewTableLayout> preferredShuffleLayout = metadata.getPreferredShuffleLayoutForNewTable(session, destination.getCatalogName(), tableMetadata);
List<String> columnNames = tableMetadata.getColumns().stream().filter(column -> !column.isHidden()).map(ColumnMetadata::getName).collect(toImmutableList());
TableStatisticsMetadata statisticsMetadata = metadata.getStatisticsCollectionMetadataForWrite(session, destination.getCatalogName(), tableMetadata);
return createTableWriterPlan(analysis, plan, new CreateName(new ConnectorId(destination.getCatalogName()), tableMetadata, newTableLayout), columnNames, tableMetadata.getColumns(), newTableLayout, preferredShuffleLayout, statisticsMetadata);
}
Aggregations