use of com.facebook.presto.spi.ColumnNotFoundException in project presto by prestodb.
the class AtopMetadata method getColumnMetadata.
@Override
public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle) {
String columnName = ((AtopColumnHandle) columnHandle).getName();
for (ColumnMetadata column : getTableMetadata(session, tableHandle).getColumns()) {
if (column.getName().equals(columnName)) {
return column;
}
}
AtopTableHandle atopTableHandle = (AtopTableHandle) tableHandle;
SchemaTableName tableName = new SchemaTableName(atopTableHandle.getSchema(), atopTableHandle.getTable().getName());
throw new ColumnNotFoundException(tableName, columnName);
}
use of com.facebook.presto.spi.ColumnNotFoundException in project presto by prestodb.
the class TestingHiveMetastore method renameColumn.
@Override
public synchronized void renameColumn(String databaseName, String tableName, String oldColumnName, String newColumnName) {
SchemaTableName name = new SchemaTableName(databaseName, tableName);
Table oldTable = getRequiredTable(name);
if (oldTable.getColumn(newColumnName).isPresent()) {
throw new PrestoException(ALREADY_EXISTS, "Column already exists: " + newColumnName);
}
if (!oldTable.getColumn(oldColumnName).isPresent()) {
throw new ColumnNotFoundException(name, oldColumnName);
}
for (Column column : oldTable.getPartitionColumns()) {
if (column.getName().equals(oldColumnName)) {
throw new PrestoException(NOT_SUPPORTED, "Renaming partition columns is not supported");
}
}
ImmutableList.Builder<Column> newDataColumns = ImmutableList.builder();
for (Column fieldSchema : oldTable.getDataColumns()) {
if (fieldSchema.getName().equals(oldColumnName)) {
newDataColumns.add(new Column(newColumnName, fieldSchema.getType(), fieldSchema.getComment()));
} else {
newDataColumns.add(fieldSchema);
}
}
Table newTable = Table.builder(oldTable).setDataColumns(newDataColumns.build()).build();
relations.put(name, newTable);
}
Aggregations