Search in sources :

Example 1 with NOT_FOUND

use of com.facebook.presto.spi.StandardErrorCode.NOT_FOUND in project presto by prestodb.

the class AccumuloClient method renameColumn.

public void renameColumn(AccumuloTable table, String source, String target) {
    if (!table.getColumns().stream().anyMatch(columnHandle -> columnHandle.getName().equalsIgnoreCase(source))) {
        throw new PrestoException(NOT_FOUND, format("Failed to find source column %s to rename to %s", source, target));
    }
    // Copy existing column list, replacing the old column name with the new
    ImmutableList.Builder<AccumuloColumnHandle> newColumnList = ImmutableList.builder();
    for (AccumuloColumnHandle columnHandle : table.getColumns()) {
        if (columnHandle.getName().equalsIgnoreCase(source)) {
            newColumnList.add(new AccumuloColumnHandle(target, columnHandle.getFamily(), columnHandle.getQualifier(), columnHandle.getType(), columnHandle.getOrdinal(), columnHandle.getComment(), columnHandle.isIndexed()));
        } else {
            newColumnList.add(columnHandle);
        }
    }
    // Create new table metadata
    AccumuloTable newTable = new AccumuloTable(table.getSchema(), table.getTable(), newColumnList.build(), table.getRowId().equalsIgnoreCase(source) ? target : table.getRowId(), table.isExternal(), table.getSerializerClassName(), table.getScanAuthorizations());
    // Replace the table metadata
    metaManager.deleteTableMetadata(new SchemaTableName(table.getSchema(), table.getTable()));
    metaManager.createTableMetadata(newTable);
}
Also used : IndexLookup(com.facebook.presto.accumulo.index.IndexLookup) NOT_FOUND(com.facebook.presto.spi.StandardErrorCode.NOT_FOUND) Text(org.apache.hadoop.io.Text) SchemaTableName(com.facebook.presto.spi.SchemaTableName) Pair(org.apache.commons.lang3.tuple.Pair) InvalidParameterException(java.security.InvalidParameterException) Locale(java.util.Locale) AccumuloSessionProperties(com.facebook.presto.accumulo.conf.AccumuloSessionProperties) AccumuloView(com.facebook.presto.accumulo.metadata.AccumuloView) Map(java.util.Map) Value(org.apache.accumulo.core.data.Value) Splitter(com.google.common.base.Splitter) FUNCTION_IMPLEMENTATION_ERROR(com.facebook.presto.spi.StandardErrorCode.FUNCTION_IMPLEMENTATION_ERROR) INVALID_TABLE_PROPERTY(com.facebook.presto.spi.StandardErrorCode.INVALID_TABLE_PROPERTY) AccumuloTableProperties(com.facebook.presto.accumulo.conf.AccumuloTableProperties) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) ZooKeeperMetadataManager(com.facebook.presto.accumulo.metadata.ZooKeeperMetadataManager) Set(java.util.Set) AccumuloColumnHandle(com.facebook.presto.accumulo.model.AccumuloColumnHandle) TabletSplitMetadata(com.facebook.presto.accumulo.model.TabletSplitMetadata) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) ConnectorSession(com.facebook.presto.spi.ConnectorSession) Domain(com.facebook.presto.spi.predicate.Domain) List(java.util.List) ColumnMetadata(com.facebook.presto.spi.ColumnMetadata) NOT_SUPPORTED(com.facebook.presto.spi.StandardErrorCode.NOT_SUPPORTED) AccumuloConfig(com.facebook.presto.accumulo.conf.AccumuloConfig) Entry(java.util.Map.Entry) Optional(java.util.Optional) Scanner(org.apache.accumulo.core.client.Scanner) Iterables(com.google.common.collect.Iterables) AccumuloRowSerializer(com.facebook.presto.accumulo.serializers.AccumuloRowSerializer) Logger(io.airlift.log.Logger) HashMap(java.util.HashMap) PrestoException(com.facebook.presto.spi.PrestoException) Indexer(com.facebook.presto.accumulo.index.Indexer) Connector(org.apache.accumulo.core.client.Connector) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ImmutableList(com.google.common.collect.ImmutableList) ALREADY_EXISTS(com.facebook.presto.spi.StandardErrorCode.ALREADY_EXISTS) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) Key(org.apache.accumulo.core.data.Key) Objects.requireNonNull(java.util.Objects.requireNonNull) ACCUMULO_TABLE_EXISTS(com.facebook.presto.accumulo.AccumuloErrorCode.ACCUMULO_TABLE_EXISTS) ACCUMULO_TABLE_DNE(com.facebook.presto.accumulo.AccumuloErrorCode.ACCUMULO_TABLE_DNE) ConnectorTableMetadata(com.facebook.presto.spi.ConnectorTableMetadata) Iterator(java.util.Iterator) Bound(com.facebook.presto.spi.predicate.Marker.Bound) AccumuloTable(com.facebook.presto.accumulo.metadata.AccumuloTable) AccumuloPageSink(com.facebook.presto.accumulo.io.AccumuloPageSink) AccumuloColumnConstraint(com.facebook.presto.accumulo.model.AccumuloColumnConstraint) Authorizations(org.apache.accumulo.core.security.Authorizations) AccumuloException(org.apache.accumulo.core.client.AccumuloException) Range(org.apache.accumulo.core.data.Range) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) INVALID_VIEW(com.facebook.presto.spi.StandardErrorCode.INVALID_VIEW) TableNotFoundException(com.facebook.presto.spi.TableNotFoundException) PartialKey(org.apache.accumulo.core.data.PartialKey) UNEXPECTED_ACCUMULO_ERROR(com.facebook.presto.accumulo.AccumuloErrorCode.UNEXPECTED_ACCUMULO_ERROR) AccumuloTable(com.facebook.presto.accumulo.metadata.AccumuloTable) ImmutableList(com.google.common.collect.ImmutableList) AccumuloColumnHandle(com.facebook.presto.accumulo.model.AccumuloColumnHandle) PrestoException(com.facebook.presto.spi.PrestoException) SchemaTableName(com.facebook.presto.spi.SchemaTableName)

Aggregations

ACCUMULO_TABLE_DNE (com.facebook.presto.accumulo.AccumuloErrorCode.ACCUMULO_TABLE_DNE)1 ACCUMULO_TABLE_EXISTS (com.facebook.presto.accumulo.AccumuloErrorCode.ACCUMULO_TABLE_EXISTS)1 UNEXPECTED_ACCUMULO_ERROR (com.facebook.presto.accumulo.AccumuloErrorCode.UNEXPECTED_ACCUMULO_ERROR)1 AccumuloConfig (com.facebook.presto.accumulo.conf.AccumuloConfig)1 AccumuloSessionProperties (com.facebook.presto.accumulo.conf.AccumuloSessionProperties)1 AccumuloTableProperties (com.facebook.presto.accumulo.conf.AccumuloTableProperties)1 IndexLookup (com.facebook.presto.accumulo.index.IndexLookup)1 Indexer (com.facebook.presto.accumulo.index.Indexer)1 AccumuloPageSink (com.facebook.presto.accumulo.io.AccumuloPageSink)1 AccumuloTable (com.facebook.presto.accumulo.metadata.AccumuloTable)1 AccumuloView (com.facebook.presto.accumulo.metadata.AccumuloView)1 ZooKeeperMetadataManager (com.facebook.presto.accumulo.metadata.ZooKeeperMetadataManager)1 AccumuloColumnConstraint (com.facebook.presto.accumulo.model.AccumuloColumnConstraint)1 AccumuloColumnHandle (com.facebook.presto.accumulo.model.AccumuloColumnHandle)1 TabletSplitMetadata (com.facebook.presto.accumulo.model.TabletSplitMetadata)1 AccumuloRowSerializer (com.facebook.presto.accumulo.serializers.AccumuloRowSerializer)1 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)1 ConnectorSession (com.facebook.presto.spi.ConnectorSession)1 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)1 PrestoException (com.facebook.presto.spi.PrestoException)1