use of io.trino.spi.connector.TableNotFoundException in project trino by trinodb.
the class AccumuloClient method renameTable.
public void renameTable(SchemaTableName oldName, SchemaTableName newName) {
if (!oldName.getSchemaName().equals(newName.getSchemaName())) {
throw new TrinoException(NOT_SUPPORTED, "This connector does not support renaming tables across schemas");
}
AccumuloTable oldTable = getTable(oldName);
if (oldTable == null) {
throw new TableNotFoundException(oldName);
}
AccumuloTable newTable = new AccumuloTable(oldTable.getSchema(), newName.getTableName(), oldTable.getColumns(), oldTable.getRowId(), oldTable.isExternal(), oldTable.getSerializerClassName(), oldTable.getScanAuthorizations());
// Validate table existence
if (!tableManager.exists(oldTable.getFullTableName())) {
throw new TrinoException(ACCUMULO_TABLE_DNE, format("Table '%s' does not exist", oldTable.getFullTableName()));
}
if (tableManager.exists(newTable.getFullTableName())) {
throw new TrinoException(ACCUMULO_TABLE_EXISTS, format("Table '%s' already exists", newTable.getFullTableName()));
}
// Rename index tables (which will also validate table existence)
renameIndexTables(oldTable, newTable);
// Rename the Accumulo table
tableManager.renameAccumuloTable(oldTable.getFullTableName(), newTable.getFullTableName());
// We'll then create the metadata
metaManager.deleteTableMetadata(oldTable.getSchemaTableName());
metaManager.createTableMetadata(newTable);
}
use of io.trino.spi.connector.TableNotFoundException in project trino by trinodb.
the class AccumuloClient method getScanAuthorizations.
/**
* Gets the scan authorizations to use for scanning tables.
* <p>
* In order of priority: session username authorizations, then table property, then the default connector auths.
*
* @param session Current session
* @param schema Schema name
* @param table Table Name
* @return Scan authorizations
* @throws AccumuloException If a generic Accumulo error occurs
* @throws AccumuloSecurityException If a security exception occurs
*/
private Authorizations getScanAuthorizations(ConnectorSession session, String schema, String table) throws AccumuloException, AccumuloSecurityException {
String sessionScanUser = AccumuloSessionProperties.getScanUsername(session);
if (sessionScanUser != null) {
Authorizations scanAuths = connector.securityOperations().getUserAuthorizations(sessionScanUser);
LOG.debug("Using session scan auths for user %s: %s", sessionScanUser, scanAuths);
return scanAuths;
}
AccumuloTable accumuloTable = this.getTable(new SchemaTableName(schema, table));
if (accumuloTable == null) {
throw new TableNotFoundException(new SchemaTableName(schema, table));
}
Optional<String> strAuths = accumuloTable.getScanAuthorizations();
if (strAuths.isPresent()) {
Authorizations scanAuths = new Authorizations(Iterables.toArray(COMMA_SPLITTER.split(strAuths.get()), String.class));
LOG.debug("scan_auths table property set, using: %s", scanAuths);
return scanAuths;
}
LOG.debug("scan_auths table property not set, using connector auths: %s", this.auths);
return this.auths;
}
use of io.trino.spi.connector.TableNotFoundException in project trino by trinodb.
the class AccumuloMetadata method renameColumn.
@Override
public void renameColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle source, String target) {
AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;
AccumuloColumnHandle columnHandle = (AccumuloColumnHandle) source;
AccumuloTable table = client.getTable(handle.toSchemaTableName());
if (table == null) {
throw new TableNotFoundException(new SchemaTableName(handle.getSchema(), handle.getTable()));
}
client.renameColumn(table, columnHandle.getName(), target);
}
use of io.trino.spi.connector.TableNotFoundException in project trino by trinodb.
the class AccumuloMetadata method getTableMetadata.
@Override
public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle table) {
AccumuloTableHandle handle = (AccumuloTableHandle) table;
SchemaTableName tableName = new SchemaTableName(handle.getSchema(), handle.getTable());
ConnectorTableMetadata metadata = getTableMetadata(tableName);
if (metadata == null) {
throw new TableNotFoundException(tableName);
}
return metadata;
}
use of io.trino.spi.connector.TableNotFoundException in project trino by trinodb.
the class AccumuloMetadata method getColumnHandles.
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) {
AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;
AccumuloTable table = client.getTable(handle.toSchemaTableName());
if (table == null) {
throw new TableNotFoundException(handle.toSchemaTableName());
}
ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder();
for (AccumuloColumnHandle column : table.getColumns()) {
columnHandles.put(column.getName(), column);
}
return columnHandles.buildOrThrow();
}
Aggregations