use of com.facebook.presto.hive.metastore.MetastoreContext in project presto by prestodb.
the class HiveMetadata method listTables.
@Override
public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) {
ImmutableList.Builder<SchemaTableName> tableNames = ImmutableList.builder();
MetastoreContext metastoreContext = getMetastoreContext(session);
for (String schemaName : listSchemas(session, schemaNameOrNull)) {
for (String tableName : metastore.getAllTables(metastoreContext, schemaName).orElse(emptyList())) {
tableNames.add(new SchemaTableName(schemaName, tableName));
}
}
return tableNames.build();
}
use of com.facebook.presto.hive.metastore.MetastoreContext in project presto by prestodb.
the class HiveMetadata method getColumnHandles.
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) {
SchemaTableName tableName = ((HiveTableHandle) tableHandle).getSchemaTableName();
MetastoreContext metastoreContext = getMetastoreContext(session);
Table table = metastore.getTable(metastoreContext, tableName.getSchemaName(), tableName.getTableName()).orElseThrow(() -> new TableNotFoundException(tableName));
return hiveColumnHandles(table).stream().collect(toImmutableMap(HiveColumnHandle::getName, identity()));
}
use of com.facebook.presto.hive.metastore.MetastoreContext in project presto by prestodb.
the class HiveMetadata method revokeTablePrivileges.
@Override
public void revokeTablePrivileges(ConnectorSession session, SchemaTableName schemaTableName, Set<Privilege> privileges, PrestoPrincipal grantee, boolean grantOption) {
String schemaName = schemaTableName.getSchemaName();
String tableName = schemaTableName.getTableName();
Set<HivePrivilegeInfo> hivePrivilegeInfos = privileges.stream().map(privilege -> new HivePrivilegeInfo(toHivePrivilege(privilege), grantOption, new PrestoPrincipal(USER, session.getUser()), new PrestoPrincipal(USER, session.getUser()))).collect(toSet());
MetastoreContext metastoreContext = getMetastoreContext(session);
metastore.revokeTablePrivileges(metastoreContext, schemaName, tableName, grantee, hivePrivilegeInfos);
}
use of com.facebook.presto.hive.metastore.MetastoreContext in project presto by prestodb.
the class HivePageSinkProvider method createPageSink.
private ConnectorPageSink createPageSink(HiveWritableTableHandle handle, boolean isCreateTable, ConnectorSession session, HiveMetadataUpdater hiveMetadataUpdater, boolean commitRequired, Map<String, String> additionalTableParameters) {
OptionalInt bucketCount = OptionalInt.empty();
List<SortingColumn> sortedBy;
if (handle.getBucketProperty().isPresent()) {
bucketCount = OptionalInt.of(handle.getBucketProperty().get().getBucketCount());
sortedBy = handle.getBucketProperty().get().getSortedBy();
} else {
sortedBy = handle.getPreferredOrderingColumns();
}
HiveWriterFactory writerFactory = new HiveWriterFactory(fileWriterFactories, handle.getSchemaName(), handle.getTableName(), isCreateTable, handle.getInputColumns(), handle.getTableStorageFormat(), handle.getPartitionStorageFormat(), handle.getCompressionCodec(), additionalTableParameters, bucketCount, sortedBy, handle.getLocationHandle(), locationService, session.getQueryId(), // TODO: Extend metastore cache scope to the entire transaction
new HivePageSinkMetadataProvider(handle.getPageSinkMetadata(), memoizeMetastore(metastore, metastoreImpersonationEnabled, perTransactionMetastoreCacheMaximumSize), new MetastoreContext(session.getIdentity(), session.getQueryId(), session.getClientInfo(), session.getSource(), getMetastoreHeaders(session), isUserDefinedTypeEncodingEnabled(session), columnConverterProvider)), typeManager, hdfsEnvironment, pageSorter, writerSortBufferSize, maxOpenSortFiles, immutablePartitions, session, nodeManager, eventClient, hiveSessionProperties, hiveWriterStats, orcFileWriterFactory, commitRequired, handle.getEncryptionInformation());
return new HivePageSink(writerFactory, handle.getInputColumns(), handle.getBucketProperty(), handle.getSchemaName(), handle.getTableName(), pageIndexerFactory, typeManager, hdfsEnvironment, maxOpenPartitions, writeVerificationExecutor, partitionUpdateCodec, partitionUpdateSmileCodec, session, hiveMetadataUpdater);
}
use of com.facebook.presto.hive.metastore.MetastoreContext in project presto by prestodb.
the class HivePartitionManager method getTable.
private Table getTable(ConnectorSession session, SemiTransactionalHiveMetastore metastore, SchemaTableName tableName, boolean offlineDataDebugModeEnabled) {
Optional<Table> target = metastore.getTable(new MetastoreContext(session.getIdentity(), session.getQueryId(), session.getClientInfo(), session.getSource(), getMetastoreHeaders(session), isUserDefinedTypeEncodingEnabled(session), metastore.getColumnConverterProvider()), tableName.getSchemaName(), tableName.getTableName());
if (!target.isPresent()) {
throw new TableNotFoundException(tableName);
}
Table table = target.get();
if (!offlineDataDebugModeEnabled) {
verifyOnline(tableName, Optional.empty(), getProtectMode(table), table.getParameters());
}
return table;
}
Aggregations