use of com.facebook.presto.Session in project presto by prestodb.
the class TestAtopSecurity method testAdminCanRead.
@Test
public void testAdminCanRead() {
Session admin = getSession("admin");
queryRunner.execute(admin, "SELECT * FROM disks");
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestAtopSecurity method testNonAdminCannotRead.
@Test(expectedExceptions = AccessDeniedException.class)
public void testNonAdminCannotRead() {
Session bob = getSession("bob");
queryRunner.execute(bob, "SELECT * FROM disks");
}
use of com.facebook.presto.Session in project presto by prestodb.
the class RenameColumnTask method execute.
@Override
public ListenableFuture<?> execute(RenameColumn statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters) {
Session session = stateMachine.getSession();
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTable());
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
String source = statement.getSource().toLowerCase(ENGLISH);
String target = statement.getTarget().toLowerCase(ENGLISH);
if (!tableHandle.isPresent()) {
throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
}
accessControl.checkCanRenameColumn(session.getRequiredTransactionId(), session.getIdentity(), tableName);
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle.get());
if (!columnHandles.containsKey(source)) {
throw new SemanticException(MISSING_COLUMN, statement, "Column '%s' does not exist", source);
}
if (columnHandles.containsKey(target)) {
throw new SemanticException(COLUMN_ALREADY_EXISTS, statement, "Column '%s' already exists", target);
}
metadata.renameColumn(session, tableHandle.get(), columnHandles.get(source), target);
return immediateFuture(null);
}
use of com.facebook.presto.Session in project presto by prestodb.
the class ColumnJdbcTable method cursor.
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint) {
Session session = toSession(transactionHandle, connectorSession);
Optional<String> catalogFilter = stringFilter(constraint, 0);
Optional<String> schemaFilter = stringFilter(constraint, 1);
Optional<String> tableFilter = stringFilter(constraint, 2);
Builder table = InMemoryRecordSet.builder(METADATA);
for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
QualifiedTablePrefix prefix = FilterUtil.tablePrefix(catalog, schemaFilter, tableFilter);
for (Entry<SchemaTableName, List<ColumnMetadata>> entry : listTableColumns(session, metadata, accessControl, prefix).entrySet()) {
addColumnRows(table, catalog, entry.getKey(), entry.getValue());
}
}
return table.build().cursor();
}
use of com.facebook.presto.Session in project presto by prestodb.
the class SchemaJdbcTable method cursor.
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint) {
Session session = toSession(transactionHandle, connectorSession);
Optional<String> catalogFilter = FilterUtil.stringFilter(constraint, 1);
Builder table = InMemoryRecordSet.builder(METADATA);
for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
for (String schema : listSchemas(session, metadata, accessControl, catalog)) {
table.addRow(schema, catalog);
}
}
return table.build().cursor();
}
Aggregations